NAME

random - Generates a random number

SYNOPSIS

random( n )

DESCRIPTION

random() generates a random number. If n is positive, it generates a number in the range [0, n) where the range includes 0 and excludes n. If n is negative, the range is [n, 0) where n is included and 0 is excluded. If n is not supplied, a random positive 16 bit number is generated in the inclusive range [0, 65,535].

RETURN VALUE

random() returns the generated random number.

EXAMPLES

The following example changes the label on the button randomly after each click.

var b

fun change() {
     var r
     r : random( 3 )

     if( .r == 0 ) {
          buttonlabel( .b, "Zero" )
     }
     else if( .r == 1 ) {
          buttonlabel( .b, "One" )
     }
     else {
          buttonlabel( .b, "Two" )
     }
}


fun init(){
     b : button( "Unclicked", change )
}

AUTHORS

Charlie Stuart cstuart11@protonmail.com
Ryan Brosius, Fall 21-22

REPORTING BUGS

First, check the Tranquility Programmer’s Manual
https://www.cs.drexel.edu/~bls96/tranquility.pdf
If the problem persists see Dr. Stuart or Charlie Stuart

Dr. Stuart: brian.l.stuart@drexel.edu
Charlie Stuart: cstuart11@protonmail.com

SEE ALSO

tranqc(1)

Tranquility Programmer’s Manual
https://www.cs.drexel.edu/~bls96/tranquility.pdf