laughincascade
laughincascade

Reputation: 31

Prevent TI-Basic to keep running with menus

I've got a pretty basic program that displays pictures upon request on a Menu, but it seems to display all of them, when I want it to display a picture and then stop... I'm really new to TI coding (only started today as a matter of fact), and the code I have so far is this:

Menu("Menu","asd",1,"asd",2,"asd",3,"asd",4,"asd",5,"^^^ fgh",6,"AS",7)
Lbl 1
Disp "TEXT"
Pause
Lbl 2
ClrDraw
RecallPic 0
Pause
Lbl 3
ClrDraw
RecallPic 1
Pause
Lbl 4
ClrDraw
RecallPic 2
Pause
Lbl 5
ClrDraw
RecallPic 3
Pause
Lbl 6
ClrDraw
RecallPic 3
Pause
Lbl 7
Disp "TEXT"
Pause

I also tried the End function but it just errors... Edit: Also, I know that label 5 and 6 display the same picture, but that's because label 6 displays the rest of the name for label 5.

Upvotes: 0

Views: 51

Answers (2)

Timtech
Timtech

Reputation: 1274

If options 5 and 6 display the same picture, you can simplify your code by pointing them to the same Lbl. Also, instead of using End like you mentioned, you should use Return like so:

Menu("Menu","asd",1,"asd",2,"asd",3,"asd",4,"asd",5,"^^^ fgh",5,"AS",7)
Lbl 1
Disp "TEXT
Return
Lbl 2
ClrDraw
RecallPic 0
Return
Lbl 3
ClrDraw
RecallPic 1
Return
Lbl 4
ClrDraw
RecallPic 2
Return
Lbl 5
ClrDraw
RecallPic 3
Return
Lbl 7
Disp "TEXT

Upvotes: 0

PR06GR4MM3R
PR06GR4MM3R

Reputation: 397

Labels only send the computer to a different point in the program, they do not stop the computer from reading your code once the label is complete. Let's say you selected option 2. Label 1 would be skipped, label 2 and the rest of the program would be executed. Same goes for all your other labels. If you select option 5, label 5 would be executed and the computer would keep reading until it reached the end of the program.

Once the code of the selected option has been executed you will want to send the computer to a common point of all the options in this case Lbl 8.

Menu("Menu","asd",1,"asd",2,"asd",3,"asd",4,"asd",5,"^^^ fgh",6,"AS",7)
Lbl 1
Disp "TEXT"
goto 8
Lbl 2
ClrDraw
RecallPic 0
goto 8
Lbl 3
ClrDraw
RecallPic 1
goto 8
Lbl 4
ClrDraw
RecallPic 2
goto 8
Lbl 5
ClrDraw
RecallPic 3
goto 8
Lbl 6
ClrDraw
RecallPic 3
goto 8
Lbl 7
Disp "TEXT"
goto 8
Lbl 8
pause

The goto 8's prevent the computer from reading the code from other options that you did not select and sends the computer to right before the pause command that you had after all of your labels in your code.

Upvotes: 1

Related Questions