
PROGRAMMING
16. CUSTOM MACRO
B–63124EN/01
272
Operators each consist of two letters and are used to compare two values
to determine whether they are equal or one value is smaller or greater than
the other value. Note that the inequality sign cannot be used.
Table 16.5.2 Operators
Operator
Meaning
EQ Equal to(=)
NE Not equal to(0)
GT Greater than(>)
GE Greater than or equal to(y)
LT Less than(<)
LE Less than or equal to(x)
The sample program below finds the total of numbers 1 to 10.
O9500;
#1=0; Initial value of the variable to hold the sum. . . . . . . . . . . . . . . . .
#2=1; Initial value of the variable as an addend. . . . . . . . . . . . . . . . .
N1 IF[#2 GT 10] GOTO 2; Branch to N2 when the addend is greater than
10
#1=#1+#2; Calculation to find the sum. . . . . . . . . . . . .
#2=#2+1; Next addend. . . . . . . . . . . . . .
GOTO 1; Branch to N1. . . . . . . . . . . . . .
N2 M30; End of program. . . . . . . . . . . . . . . .
Specify a conditional expression after WHILE. While the specified
condition is satisfied, the program from DO to END is executed. If the
specified condition is not satisfied, program execution proceeds to the
block after END.
WHILE [conditional expression] DO m ; (m=1,2,3)
END m ;
:
Processing
If the condi-
tion is not sa-
tisfied
If the condi-
tion is satis-
fied
While the specified condition is satisfied, the program from DO to END
after WHILE is executed. If the specified condition is not satisfied,
program execution proceeds to the block after END. The same format as
for the IF statement applies. A number after DO and a number after END
are identification numbers for specifying the range of execution. The
numbers 1, 2, and 3 can be used. When a number other than 1, 2, and 3
is used, alarm No. 126 occurs.
D Operators
Sample program
16.5.3
Repetition
(While Statement)