Making a Program Wait for Numeric Input


This section explains how to interrupt a program so that you can enter numbers into the program.


Using [ BREAK ] to Enter Numbers

Many problems require you to enter a number after a sequence of keystrokes has already been performed. To solve this type of problem in a program, you need an instruction that:
  • Interrupts the program at the point where you want to enter the number.
  • Permits you to perform manual calculator operations such as entering a number into the display.
  • Allows you to continue execution from the point in the program where it was interrupted.

The [ BREAK ] instruction is designed for this purpose.

[ BREAK ] interrupts program execution and defines [ F1 ] as { GO }. By placing a [ BREAK ] instruction in a program, you can stop execution temporarily. When you are ready to restart the program, just press { GO }. If you clear { GO } by pressing a system-menu key before you restart the program, you can restore { GO } by pressing [ BREAK ].

The use of a [ BREAK ] instruction to enter a number into a program is illustrated below.

[ RUN ] { PGM }
... program executes
BRK
Enter Number
{ GO }
... program executes
HLT

Example

Write a program to solve the following problem.

Z = SIN X - TAN Y

This problem requires you to enter values for X and Y. Design the program so that you enter X before you run the program and Y after execution starts.

Procedure

Press

Display

Activate learn mode[ LEARN ]
{ 1st }
Clear program[ 2nd ]
[ CP ]
D_SQUHYh
Calculate sine[ SIN ]D_NJGBt4
Subtract[ - ]D_ivXtxc
Stop for number[ BREAK ]D_RbADL5
Calculate tangent[ TAN ]D_EymRnQ
Final result[ = ]D_lUfKko
Stop execution[ HALT ]D_phpX9h
Exit learn mode[ LEARN ]D_cpVRp4



Running the Example

Before running the program, set the angle units to grads by pressing [ 2nd ] [ DRG ] until GRAD MODE appears in the display. Then use the program to calculate Z for the following values of X and Y.

Value of X

Value of Y


206 Grads94 Grads
45 Grads101 Degrees




Procedure

Press

Display

Set grad mode[ 2nd ] [ DRG ] •D_yzCL7w
Display RUN menu[ RUN ]D_976pMM
Enter X206
{ PGM }
D_vDH12x
Enter Y94
{ GO }
D_4Ft7U3
Display RUN menu[ RUN ]D_976pMM
Enter X45
{ PGM }
D_3oWyoH
Select ANG menu[ CONV ]
{ ANG }
D_kz0evm
Enter Y, Convert to grads101
{ D-G }
D_fV6PZX
Redisplay { GO }[ BREAK ]D_MHmkVa
Restart program{ GO }D_ldqgC5

• Repeat until GRAD MODE appears in the display.

Note:

Running a program does not clear calculations in progress. Therefore, if you decide to rerun the program after it has been stopped by the BRK instruction, press [ CLEAR ] first to clear the pending calculation.

Back