Creating a Menu (Looping?)


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262

    Default Creating a Menu (Looping?)

    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.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    PBP 2.60 or higher ...
    Code:
    ON X GOTO Main, Menu1, Menu2, Menu3, Menu4
    DT

  3. #3
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Creating a Menu (Looping?)

    Cool that works, Thanks Darrel
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

Similar Threads

  1. Looping through MyVar.n - will this work?
    By kjavrd in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th November 2012, 23:47
  2. SerIn Looping problem ???
    By gtvmarty in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th September 2009, 00:31
  3. Looping Variable Assignments
    By jcb344 in forum General
    Replies: 3
    Last Post: - 5th July 2008, 09:50
  4. looping / counter
    By tech in forum General
    Replies: 3
    Last Post: - 18th May 2008, 23:31
  5. looping
    By lerameur in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 11th February 2007, 14:41

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts