6.1.5 Conditions and Program Flow Control


The program flow control of macro mode A has three conditional forms:IFIF…ELSEWHILE


1. IF

Format:

IF variable P end line number


Example:

IF #100 P100;
G00 X#3 Y100;
G01 X100 Y#2 F#8;
N100 G53 X0 Z0;
G01 X300 F0.1;
M30;


If the variable #100 value is "non-zero", the program will execute as follows:

G00 X#3 Y100;
G01 X100 Y#2 F#8;
N100 G53 X0 Y0;
G01 X300 F0.1;
M30;


If the variable #100 value is "zero", the program will execute as follows:

G01 X300 F0.1;
M30;


2. IF…ELSE

Format:

IF variable P end of line number A

N end line number A

ELSE P ending line number B

N ending line number B


Example:

IF #1 P100
G00 X800 Y1000;
G01 X1000 Y200 Z-10;
N100 G00 X0 Y0 Z0
ELSE P200
G00 X1600 Y1000;
G01 X1800 Y200 Z-10;
N200 G00 X0 Y0 Z0;
M30;


If the variable #1 value is "non-zero", the program will execute as follows:

G00 X800 Y1000;
G01 X1000 Y200 Z-10;
G00 X0 Y0 Z0;
M30;


If the variable #1 value is "zero", the program will execute as follows:

G00 X1600 Y1000
G01 X1800 Y200 Z-10;
G00 X0 Y0 Z0;
M30;


3. WHILE

Format:

WHILE variable P end line number


Example:

#7=4;

WHILE #7 P80

G90 G01 Z-10 F0.8;

G91 G01 X100 F1.0;

#7=#7-1;

N80 G90 G01 Z0 F0.8;


the program will execute as follows:

G90 G01 Z-10 F0.8;

G91 G01 X100 F1.0;

G90 G01 Z0 F0.8;

G90 G01 Z-10 F0.8;

G91 G01 X100 F1.0;

G90 G01 Z0 F0.8;

G90 G01 Z-10 F0.8;

G91 G01 X100 F1.0;

G90 G01 Z0 F0.8;

G90 G01 Z-10 F0.8;

G91 G01 X100 F1.0;

G90 G01 Z0 F0.8;


Note:

The above three judgment formulae: IFIF…ELSEWHILE nested conditional evaluation can only have 8 layers.