Using the YES/NO Test


The Y/N test gives you an easy way to let the user control the program by answering yes or not to a question. Unlike the tests discussed previously in this chapter, the Y/N test does not compare any numeric values in the program.


The YES/NO Test

When you press [ TESTS ], you can the Y/N test into your program.
D_9Wf8v5
{ Y/N } - Defines the [ F1 ] key as YES and the [ F2 ] key as NO and halts the program. This lets the user of your program responde to an alpha message you have placed in the display.

If you press { NO } in response to the Y/N test, the first instruction following the test is skipped. If you press { YES } in response to the Y/N test, execution continues in normal sequential order.
yn
Although you could create a yes/no menu using the DFN instruction, the Y/N test has the following advantages whenever you want a program to pose a yes/no question.
  • You do not have to include { YES } and { NO } function key definitions.
  • You do not have to include a HLT instruction in the program.
  • You do not have to clear any function key definitions. (The calculator clears the definitions automatically.)

Example

The following program creates a loop that calculates the square roots of a sequence of numbers beginning with 1. The program uses a Y/N test to ask if you want to sum each result to data register B.

PC =

Program Mnemonics

Comments

0000 0 STO A STO BInitializes A and B
0005LBL AABegins loop
0008 INC AIncrements count
0010 RCL AGets current count
0012 SQRCalculates square root
0013 PAUDisplays square root
0014 `SUM TO B?`Creates message
0023 Y/NYES/NO test
0024 ST+ B{ YES } - Sum to B
0026 GTL AARepeats loop



Running the Example

Run the program and sum the values of the first and third square roots.

Procedure

Press

Display

Start the program[ RUN ]
{ PGM }
D_LLlugg
D_fiUI9J
Sum 1st number{ YES }D_gp8Kxt
D_fiUI9J
Don't sum 2nd number{ NO }D_0cZWPQ
D_fiUI9J
Sum 3rd number{ YES }D_dBdVZT
D_fiUI9J
Check the sum[ RCL ] BD_ZlvWHm
Clear function keys[ 2nd ]
[ F:CLR ]
D_RbDtF5


Back