This program shows you how to use the rand, random number generator command. It will generate a random number between zero and five each time the main program loop runs. If the number generated is 4 the program will exit and print BOOM!.
You can use random numbers in programs where you want an event to occur at an unpredictable time.
When the program runs it will exit after a random interval. This interval is dependent on how quickly the number 4 arises in the random number sequence.
Random Number Test Program
This program will generate a random number between zero and five.
It Will wait until the number four comes up and then exit.
print "Random Number Test Program"
rand 0 5 -> /randno
print "Count /count rand /randno"
any /randno = 4 -> "BOOOM!"|exitprog
print "Prog STOPPED!"