Parallax BASIC Stamp 2e Programming Manual page 134

Table of Contents

Advertisement

GOSUB - BASIC Stamp Command Reference
FOR Rounds = 1 TO 3
DEBUG CLS,"Pick a number from 1 to 10", CR
GOSUB PickANumber
PAUSE 2000
DEBUG "My number was: ", DEC MyNum
PAUSE 2000
NEXT
STOP
' 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
MyNum = NumGen / 6550 MIN 1
RETURN
Page 132 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
' Go three rounds.
' Get a random number, 1-10.
' Dramatic pause.
' Show the number.
' Another pause.
' When done, stop execution here.
' Stir up the bits of NumGen.
' Scale to fit 1-10 range.
' Go back to the 1st instruction
' after the GOSUB that got us here.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Table of Contents