|
Section 4: Programming 159
|
|
If the pointer is at the bottom. and you try to insert a step, the code(s) will be generated in
the display, but will not go into memory. Deleting the bottom step also deletes the step ahead
of it. For a critical case like this. be sure to reinsert the last step.
|
|
Test Operations
|
To complete the discussion of programming the HP-65, we will consider the test operations summarized in
Figure 4-5. The test operations are particularly valuable for performing iterative calculations.
|
|
Using the Flags for Programmed Decisions
|
|
The calculator has two flags (called flag 1 and flag 2) available for your use. A flag is
an invisible piece of information with just two possible conditions: on or off.
The flag operations are given in Figure 4-5. p. 63. You can set a flag on or off
by using the Set Flag operations. These operations can be executed from the keyboard or from a program.
The reason for setting a flag is so that a program can later make a decision based on the condition
of the flag (using the test flag operations).
|
|
Sample Case. Flags. Create a function A that computers (1/x)2 if flag 1 is
on and computes (x2) if flag 1 is off. Assume that the desired condition of
flag 1 has been previously set.
|
|
|
Switch to W/PRGM
|
|
|
Clear memory by pressing fPRGM
|
|
|
Key in the following steps.
|
|
|
Keys
|
|
|
Comment
|
|
LBL A
|
|
|
|
|
fTF1
|
|
|
Test flag 1 for on.
|
|
g
|
|
|
If on, calculate (1/x).
|
1/x
|
|
f-1
|
|
|
Square x or 1/x.
|
|
RTN
|
|
|
Stop.
|
|
|
|
If flag is on, these two steps are not skipped. If off, they are skipped and x is
not replaced by 1/x.
|
|