Conditional Instructions-Decisions And Control - HP -20S Owner's Manual

Scientific calculator
Hide thumbs Also See for HP-20S:
Table of Contents

Advertisement

The (=]
label instruction transfers the execution of a running
program to the program line containing that label, wherever it may
be. Searching starts at [(¥]
and continues throughout all of pro-
gram memory. The program continues running from the new location.
It does not automatically return to its point of origin when a [¢>]
is encountered. Consequently, (%]
is not used for subroutines.
Conditional Instructions—Decisions and Control
In addition to subroutines, another way to control pro-
gram execution is with a conditional test—a true/false test
that compares two numbers and skips the next program
instruction if the comparison is false.
The HP-20S has two conditional statements: they are ()
and
(] (x=0?]. x<y? asks the question, "Is x less than or equal to y?" x=0?
asks the question, "Is x equal to 0?" If the answeris true, the program
continues execution with the line immediately following the question.
If the answer is false, the program skips one line and continues from
there.
For instance, if a conditional instruction is x=0?, then the program
compares the contents of the display to zero. If there is a zero in the
display, then the program goes on to the next line. If there is not a
zero in the display, then the program skips one line and continues
from there. This rule is commonly known as "Do if true."
For x<y?, the program compares y (the displayed value) with x (the
hidden value). Use
or any other operator (for example,
or
(+]) to separate x and y. If x is less than or equal to y, then the pro-
gram goes on to the next line. If x is not less than or equalto y (that is,
x is greater than y), then the program skips one line and continues
from there.
The following example illustrates conditional branching and a GTO
statement.
6: Programming
81

Advertisement

Table of Contents
loading

Table of Contents