Loop commands – HP 38g Graphing Calculator User Manual
Page 169
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".
Loop Commands
A programming structure allows a program to control how it
should execute depending on given conditions or the values
of particular arguments. The HP 38G has two kinds of control
structures;
® Branch structures.
• Loop structures
DO...UNTIL
...END
Do ... Until... End
is a loop structure that executes the
loop-
clause
repeatedly until
test-clause
returns a true (nonzero) result.
Because the test is executed
after
the loop>clause, the loop-clause
is always executed at least once. Its syntax is;
DO
loop-clause
UNTIL
test-clause
END
WHILE...
REPEAT...
END
While ... Repeat... End
is a loop structure that repeatedly
evaluates
test
and executes
loop
sequence if the test
is true. Because the test-clause is executed before the loop-
clause, the loop-clause is not executed if the test is initially false.
Its syntax is;
WHILE
test-clause
REPEAT
loop-clause
END
FOR I ...TO
...STEP
...END
FOR
name=start-expression
TO
end-expression
STEP INCREMENT;
loop-clause
END
Exeunple
FOR 1=1 to 300
STEP 30;
BEEP 800-H; .5:
END
BREAK
Terminates loop.
Programming 8-17