Programming 527
IFERR IFERR commands1 THEN commands2 END;
Executes sequence of commands1. If an error occurs
during execution of commands1, executes sequence of
commands2.
IFERR ELSE IFERR commands1 THEN commands2 ELSE
commands3 END;
Executes sequence of commands1. If an error occurs
during execution of commands1, executes sequence of
commands2. Otherwise, execute sequence of
commands3.
Loop
FOR Syntax: FOR var FROM start TO finish DO commands END;
Sets variable var to start, and for as long as this variable
is less than or equal to finish, executes the sequence of
commands, and then adds 1 (increment) to var.
Example 1: This program determines which integer from 2
to N has the greatest number of factors.
EXPORT MAXFACTORS(N)
BEGIN
LOCAL cur, max,k,result;
1
max;1 result;
FOR k FROM 2 TO N DO
SIZE(idivis(k))
cur;
IF cur > max THEN
cur
max;
k
result;
END;
END;
MSGBOX("Max of "+ max +" factors for
"+result);
END;