HP (Hewlett-Packard) 35s Calculator User Manual


 
Programming Techniques 14-13
It is good practice in a program to make sure that any conditions you will be testing
start out in a known state. Current flag settings depend on how they have been left
by earlier programs that have been run. You should not assume that any given flag
is clear, for instance, and that it will be set only if something in the program sets it.
You should make sure of this by clearing the flag before the condition arises that
might set it. See the example below.
Example: Using Flags.
If you write lines S002 CF0 and S003 CF1(as shown above), the flags 0 and 1 are
cleared so lines S006 and S010 do not take the natural logarithms of the X- and Y-
inputs.
If you replace lines S002 and S003 by SF 0 and CF 1, then flag 0 is set so line
S006 takes the natural log of the X-input.
If you replace lines S002 and S003 by CF 0 and SF1, then flag 1 is set so line
S010 takes the natural log of the Y-input.
Program Lines:
(In RPN mode)
Description:
 
  Clears flag 0, the indicator for In X.
  Clears flag 1, the indicator for In Y.
  Prompts for and stores X
  If flag 0 is set…
  … takes the natural log of the X-input
  Stores that value in X after flag test
  Prompts for and stores Y
  If flag 1 is set…
  … takes the natural log of the Y-input
  Stores that value in Y after flag test
  Displays value
  Displays value
 
Checksum and length: 16B3 42