Creating a Function-Key Menu


When using a menu, you must design the program so that each function key transfers control to a specific program segment. Typically, you place a HLT instruction at the end of each segment to prevent the calculator from executing past the segment.


Building a Menu

To create a menu in a program, use a separate DFN instruction for each function key you want to define. After the final function key is defined, put a HLT instruction at the point in the program where you want the definitions displayed.

The following illustration shows how you structure a program for a three function menu. Pressing [ F1 ], [ F2 ], or [ F3 ] transfers program execution to label AA, BB, or CC, respectively.

These instructions define the menu shown below:
DFN F1:1st@AA
DFN F2:2nd@BB
DFN F3:3rd@CC
HLT


D_2icgpZ

LBL AA <--- [ F1 ]
...
HLT
LBL BB <--- [ F2 ]
...
HLT
LBL CC <--- [ F3 ]
...
HLT


Example Program 1

Write a program that creates a menu with options to calculate the third, fourth, or fifth root of a number.

PC =

Program Mnemonics

Comments

0000`ROOTS`Create a menu title
0005 DFN F1:3RD@AADefines F1
0012 DFN F2:4TH@BBDefines F2
0019 DFN F3:5TH@CCDefines F3
0026 HLTStops program and displays menu
0027LBL AALabels segment
0030 (INV y^x 3)Calculates third root
0035 HLTStops program
0036LBL BBLabels segment
0039 (INV y^x 4)Calculates fourth root
0044 HLT</td>Stops program
0045LBL CCLabels segment
0048 (INV y^x 5)Calculates fifth root
0053 HLTStops program


Running Example 1

Test the program by calculating the third and fifth roots of a number.

Procedure

Press

Display

Activate the menu[ RUN ]
{ PGM }
D_vult2X
Enter a number8D_602gAZ
Calculate 3rd root{ 3RD }D_yyXFdO
Enter a number3125D_V6dpL8
Calculate 5th root{ 5TH }D_mUeai2


Example Program 2


This example lets you use the function keys to enter sides a and b of a right triangle. When you press { CAL }, the program calculates the length of the hypotenuse. (If the keyboard is not in lowercase lock, use [ 2nd ] A and [ 2nd ] B to enter the lowercase letters a and b.)

PC =

Program Mnemonics

Comments

0000`ENTER SIDES`Creates menu title
0011 DFN F1:a @SADefines F1
0018 DFN F2:b @SBDefines F2
0025 DFN F5:CAL@CHDefines F5
0032 HLTStops program and displays menu
0033LBL SALabels segment
0036 STO A HLTStores side a in register A
0039LBL SBLabels segment
0042 STO B HLTStores side b in register B
0045LBL CHLabels segment
0048 (RCL A x^2Calculates hypotenuse
0052 + RCL B x^2) SQR
0058 `HYP=`Creates alpha message
0062 COL 16 MRG =Merges result
0066 HLTStops program


Running Example 2

Test the program by entering values that describe a "3-4-5" triangle.

Procedure

Press

Display

Activate the menu[ RUN ]
{ PGM }
D_y6aCNu
Enter side a30 { a }D_rOhX5Y
Enter side b40 { b }D_9ZFLKL
Calculate hypotenuse{ CAL }D_iZFTAN


Back