random - Generates a random number
random( n )
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].
random() returns the generated random number.
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 ) }
Charlie Stuart
cstuart11@protonmail.com
Ryan Brosius, Fall 21-22
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
tranqc(1)
Tranquility
Programmer’s Manual
https://www.cs.drexel.edu/~bls96/tranquility.pdf