EasyManua.ls Logo

Parallax BASIC Stamp 2e - Page 134

Default Icon
353 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
GOSUB - BASIC Stamp Command Reference
Page 132 BASIC Stamp Programming Manual 2.0b www.parallaxinc.com
FOR Rounds = 1 TO 3 ' Go three rounds.
DEBUG CLS,"Pick a number from 1 to 10", CR
GOSUB PickANumber ' Get a random number, 1-10.
PAUSE 2000 ' Dramatic pause.
DEBUG "My number was: ", DEC MyNum ' Show the number.
PAUSE 2000 ' Another pause.
NEXT
STOP ' When done, stop execution here.
' Random-number subroutine. A subroutine is just a piece of code with the RETURN
' instruction at the end. Always make sure your program enters subroutines with a GOSUB.
' If you don't, the RETURN won't have the correct address, and your program will have a bug!
PickANumber:
RANDOM NumGen ' Stir up the bits of NumGen.
MyNum = NumGen / 6550 MIN 1 ' Scale to fit 1-10 range.
RETURN ' Go back to the 1st instruction
' after the GOSUB that got us here.

Table of Contents

Related product manuals