13–12 Programming Techniques
File name 32sii-Manual-E-0424
Printed Date : 2003/4/24 Size : 17.7 x 25.2 cm
Using Flags
Pressing
{
x
displays the FLAGS menu: {
} {
} {
@
}
After selecting the function you want, you will be prompted for the flag
number (0–11). For example, press
{
x
{
} 0 to set flag 0; press
{
x
{
}
to set flag 10; press
{
x
{
}
1 to set
flag 11.
FLAGS Menu
Menu Key Description
{
} n Set flag. Set flag n.
{
} n Clear flag. Clears flag n.
{
@
} n Is flag set
?
Tests the status of flag n.
A flag test is a conditional test that affects program execution just as the
comparison tests do. The FS
?
n instruction tests whether the given flag is set. If
it is, then the next line in the program is executed. If it is not, then the next line
is skipped. This is the "Do if True" rule, illustrated under "Conditional
Instructions" earlier in this chapter.
If you test a flag from the keyboard, the calculator will display "
&
" or
"
".
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.
The "Curve Fitting" program in chapter 16 uses flags 0 and 1 to determine
whether to take the natural logarithm of the X– and Y–inputs:
Lines S03 and S04 clear both of these flags so that lines W07 and W11
(in the input loop routine) do not take the natural logarithms of the X–
and Y–inputs for a Straight–line model curve.