# Fanuc Power Mate i-D/H Operator Manual

PROGRAMMING
(Common to Power Mate i–D and –H)
13. CUSTOM MACRO
B–63174EN/03
122
In a program, the flow of control can be changed using the GOTO
statement and IF statement. Three types of branch and repetition
operations are used:
Branch and repetition GOTO statement (unconditional branch)
IF statement (conditional branch: if ..., then...)
WHILE statement (repetition while ...)
A branch to sequence number n occurs. When a sequence number outside
of the range 1 to 99999 is specified, alarm No.128 occurs. A sequence
number can also be specified using an expression.
GOTO n ; n: Sequence number (1 to 99999)
Example:
GOTO1;
GOTO#10;
Specify a conditional expression after IF. If the specified conditional
expression is satisfied, a branch to sequence number n occurs. If the
specified condition is not satisfied, the next block is executed.
IF [#1 GT 10] GOTO 2 ;
N2 G00 G91 X10.0 ;
:
If the value of variable #1 is greater than 10, a branch to sequence number
N2 occurs.
If the condi-
tion is not sa-
tisfied
Processing
If the condition is satisfied
A conditional expression must include an operator inserted between two
variables or between a variable and constant, and must be enclosed in
brackets ([, ]). An expression can be used instead of a variable.
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 13.5.2 Operators
Operator
Meaning
EQ Equal to(=)
NE Not equal to()
GT Greater than(>)
GE Greater than or equal to()
LT Less than(<)
LE Less than or equal to()
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
GOTO 1 ; Branch to N1
N2 M30 ; End of program
13.5
BRANCH AND
REPETITION
13.5.1
Unconditional Branch
(GOTO Statement)
13.5.2
Conditional Branch
(IF Statement)
Explanations
Conditional expression
Operators
Sample program