Help.. Passing a Debug value to a GOTO command?
robo101.com
Posts: 2
Help...
I would like to enter a value in to the debug window and have my BS2 use the value to determine what code to run by way of the GOTO command..
In short I want the GOTO command to use a variable/value·that I enter from the debug window..
Here is code I think should work but is not..
'################ Start example code ##############
' {$STAMP BS2}
' {$PBASIC 2.5}
myNum VAR Word
GOTO R1
R1:
DEBUG CLS, "Enter a any number: " ' prompt user
DEBUGIN mynum
GOTO mynum
··
R2:
DEBUG "You slected run the gode in " mynum, CR
PAUSE 1000
GOTO R1
R3:
DEBUG "This time you selected " mynum, CR
PAUSE 5000
GOTO R1
'################ End example code ##############
Error: I get an "expected label" in the GOTO of R1:··
(how should I be trying to pass the enterd value such as "R2" to the GOTO??)
Thanks for the help!
Shane
I would like to enter a value in to the debug window and have my BS2 use the value to determine what code to run by way of the GOTO command..
In short I want the GOTO command to use a variable/value·that I enter from the debug window..
Here is code I think should work but is not..
'################ Start example code ##############
' {$STAMP BS2}
' {$PBASIC 2.5}
myNum VAR Word
GOTO R1
R1:
DEBUG CLS, "Enter a any number: " ' prompt user
DEBUGIN mynum
GOTO mynum
··
R2:
DEBUG "You slected run the gode in " mynum, CR
PAUSE 1000
GOTO R1
R3:
DEBUG "This time you selected " mynum, CR
PAUSE 5000
GOTO R1
'################ End example code ##############
Error: I get an "expected label" in the GOTO of R1:··
(how should I be trying to pass the enterd value such as "R2" to the GOTO??)
Thanks for the help!
Shane
Comments
kelvin
Post Edited (kelvin james) : 5/6/2005 5:53:15 AM GMT
Parallax PBASIC (as you will learn) has no computer GOTO command per se, but it does have another equivalent command. Take a look in the Help File or better yet in the MANUAL (free for the download) at the ON [noparse][[/noparse]variable name] GOTO [noparse][[/noparse]label 1, label 2 ...] construct.
Regards,
Bruce Bates
· ON offset GOTO Targe0, Target1, Target2
· ' if here, offset was > 2
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA