Loop commands – HP 39g Graphing Calculator User Manual
Page 230
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".
REPLACE
SUB
ZEROGROB
Replaces portion of graphic in graphicnamel with
graphicnamel, starting at position . REPLACE also works
for lists and matrices.
REPLACE graphicnamel; (position); graphicnamel:
Extracts a portion of the named graphic (or list or matrix), and
stores it in a new variable, name. The portion is specified by
position and positions.
SUB name; graphicname; (position); (positions):
Creates a blank graphic with given width and height, and
stores it in graphicname.
ZEROGROB graphicname; width; height:
Loop commands
DO...UNTIL
...END
WHILE...
REPEAT...
END
Loop structures allow a program to execute a routine
repeatedly. The HP 39G/40G has three loop structures. The
example programs below illustrate each of these structures
incrementing the variable A from 1 to 12.
Do ...Until... End isaloop structure that executes the/oop-
claiise 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
1 ► A:
DO A + 1 ► A
UNTIL A == 12
END
While ... Repeat... End is a loop structure that repeatedly
evaluates test-clause and executes loop-clause 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
1 ► A:
WHILE A < 12
REPEAT A+1 ► A
END
15-22
Programming