Can I put a few LABELS in a lookup table? If yes how can I then use the label returned to make the program GOTO that label? GOTO does not work with a variable.
Thanks
Surfies
Printable View
Can I put a few LABELS in a lookup table? If yes how can I then use the label returned to make the program GOTO that label? GOTO does not work with a variable.
Thanks
Surfies
Use ON GOTO or ON GOSUB.
Do what Darrel says. :)
However, if you need to intermix things in a LOOKUP table, then here is a method to achieve that:
Code:lbl_1stPlace CON $FF
lbl_2ndPlace CON $FE
lbl_3rdPlace CON $FD
lbl_4thPlace CON $FC
My_Index_Var VAR WORD
MY_LOOKUP_Var VAR WORD
'-----------------------------------------------------------------
LOOKUP My_Index_Var, [1,2, lbl_1stPlace,3,4, lbl_2ndPlace ,5,6, lbl_3rdPlace,7,8, lbl_4thPlace,9,10], MY_LOOKUP_Var
SELECT CASE MY_LOOKUP_Var
CASE lbl_1stPlace GOTO 1stPlace
CASE lbl_2ndPlace GOTO 2ndPlace
CASE lbl_3rdPlace GOTO 3rdPlace
CASE lbl_4thPlace GOTO 4thPlace
END SELECT
'-----------------------------------------------------------------
1stPlace:
'-----------------------------------------------------------------
2ndPlace:
'-----------------------------------------------------------------
3rdPlace:
'-----------------------------------------------------------------
4thPlace:
Thanks Darrel and SteveB will try that and let you know.
This ON GOTO command, does it work with PBP 2.32 ?? here is part of the code;
COUNT PORTC.3, 15000, c1 'put pulses in C1
ON c1 GOTO S1,S2,S3,S4,S5,S6,S7,S8 I get a syntax error on this line, do I miss something? S1 to S8 is labels, C1 is defined as a variable.
Thanks.
:confused:Quote:
does it work with PBP 2.32 ???
Wowwww !!!
PBP2.32 might be @ least 10 years old ... more than time to upgrade !
my 2.50 version manual does not show ON GOxxx commands ( appears in the v2.60 manual ), sooo ... prepare your :greedy_dollars:
Alain
Aag ja that explains it.
thanks for the help and the quick response, nice to have willing clever people on line.
will just have to make a plan now.
Hi, Surfies
Could have been much easier for us YOU to explain what you physically tried to do ...
I smell some kind of overkill trick here :D
Alain
There is a push button on portc.3, then depending on how many times its pressed, ( up to 8 times ) the program must then jump to that number's sub routine. I hope that make sense.
so ...Quote:
then depending on how many times its pressed, ( up to 8 times ) the program must then jump to that number's sub routine.
a "basic" set of IF ... THEN ... GOTO is the trick.
SELECT CASE is the smart way to write it ... but is it available with v 2.32 ???
LOOKUPx is generally used to retrieve constants/values/strings from a table , not label adresses.
Alain
Yes, IF......THEN's is what I'll have to do , thought I could get away without them.
Thanks a lot for all the help.