Random Number Test

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.

Program


---

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.

---


prog_vars =

d/count 1

d/randno 0

prog_vars.


prog_start =

print "Random Number Test Program"

prog_start.


prog_loop =


rand 0 5 -> /randno


print "Count /count rand /randno"

any /randno = 4 -> "BOOOM!"|exitprog

inc /count


prog_loop.


prog_stop =

print "Prog STOPPED!"

prog_stop.