Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4745

Creating a Menu (Looping?)

$
0
0
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.

Code:

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)

Code:

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.

Viewing all articles
Browse latest Browse all 4745

Trending Articles