Ti-83 Programming Tutorials

Home About Projects Links Tutorials

Chapter 8 - Custom Menus/GUI

Custom menus simply are menus that you create yourself using your own coding instead of the Menu function. Custom menus allow you to implement your own graphical user interface and display whatever information you want onto the screen.

Implementation
There are many ways that you can implement your own custom menu. Below is an example of implementing one onto the home screen.
Lbl 0
ClrHome
Output(1,1,"CUSTOM MENU")
Output(2,3,"OPTION 1")
Output(3,3,"OPTION 2")
Output(4,3,"OPTION 3")
1->A
Output(2,1,"=>")
Repeat K=21
getKey->K)
If (K=25) or (K=34)
Then
Output(A+1,1,"  ")
A-(K=25)+3(K=25)(A=1)+(K=34)-3(K=34)(A=3)->A
Output(A+1,1,"=>")
End
End
ClrHome
If A=1
Goto 1
If A=2
Goto 2
If A=3
Goto 3
Lbl 1
Disp "YOU PICKED 1"
Stop
Lbl 2
Disp "YOU PICKED 2"
Stop
Lbl 3
Disp "YOU PICKED 3"
What basically happens is the screen is set up with the options displayed. A control variable 'A' is used to keep track which menu is currently selected, and is set to 1 (the first menu slot). The repeat loop will repeat until the user hits the [2nd] button.

If the user hits the up or down arrow (25 = up arrow; 34 = down arrow) then we erase the arrow. Now comes a somewhat lengthy line of code:
A-(K=25)+3(K=25)(A=1)+(K=34)-3(K=34)(A=3)->A
It's quite simple, actually. A is the control variable. If the up arrow is hit, (K=25), then 1 is subtracted from A. If the up arrow is hit (K=25) and the first menu item was already selected (A=1) then we would have to increase A by 3 to loop it back around to the third slot. Since we already would have subtracted 1 from A if the up arrow was hit, then adding 3 would bring us back to the third slot. The rest of the line deals with the down arrow, with the same concepts as hitting the up arrow.

Using a line like this eliminates the need for if statements that may slow down the execution of the custom menu.

Having knowledge to make a custom menu screen doesn't limit you to implementing coding specifically for custom menus. You can adapt the code for various types user input/graphical output needs.



This site best viewed in Microsoft Internet Explorer (6.0+).
Copyright 2003 by Lue Her and Andy Becker.
1