BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – SELECT...CASE
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 391
test VAR Byte ' counter for tests
sample VAR Word ' random number to be tested
odd VAR Byte ' odd throws
even VAR Byte ' even throws
isLo VAR Byte ' sample in lower third
isMid VAR Byte ' in middle thrid
isHi VAR Byte ' in upper third
Main:
sample = 11000 ' initialize seed
FOR test = 1 TO 100 ' "throw" 100 times
RANDOM sample ' randomize
IF (sample.BIT0) THEN ' check odd/even bit
odd = odd + 1 ' increment odd count
ELSE
even = even + 1 ' increment even count
ENDIF
SELECT sample
CASE <= 21845 ' test lower third
isLo = isLo + 1
CASE 21846 TO 43691 ' test middle third
isMid = isMid + 1
CASE ELSE ' otherwise upper third
isHi = isHi + 1
ENDSELECT
NEXT
Show_Results:
DEBUG CLS,
"Odd Throws.... ", DEC odd, "%", CR,
"Even Throws... ", DEC even, "%", CR,
"Low........... ", DEC isLo, "%", CR,
"Mid........... ", DEC isMid, "%", CR,
"High.......... ", DEC isHi, "%", CR
END