PDA

View Full Version : Creating a Menu (Looping?)



wdmagic
- 24th April 2013, 00:38
Ok now that I have my INT's working, LCD's, & Keypad. I need to make a menu and have it go to that area(loop/Label) when last code completed and program returns to main loop. here is my code that I could use right now.


Main:
PAUSE 500
LCDOUT $FE, 1
LCDOUT $FE, $80
IF X = 0 then goto MAIN
if x = 1 then goto menu1
if x = 2 then goto menu2
if x = 3 then goto menu3
if x = 4 then goto menu4
GOTO Main
Menu1:
LCDOUT "MENU ITEM #1"
goto main
Menu2:
LCDOUT "MENU ITEM #2"
goto main
Menu3:
LCDOUT "MENU ITEM #3"
goto main
Menu4:
LCDOUT "MENU ITEM #4"
goto main
End




What I would like to do is not have all those "if x = 1 then goto" statements, what would be cool is if this code below worked (but it cant)


Main:
PAUSE 500
LCDOUT $FE, 1
LCDOUT $FE, $80
GOTO Menu[X]



But this is not allowed because you cant create a label array dangit...

Any ideas on cutting code down, I will have 16 menu items in the end so its going to get big.

Darrel Taylor
- 24th April 2013, 01:00
PBP 2.60 or higher ...


ON X GOTO Main, Menu1, Menu2, Menu3, Menu4

wdmagic
- 24th April 2013, 01:05
Cool that works, Thanks Darrel