
4 PROGRAM CODES
4 - 6
NJ/NY-series G code Instructions Reference Manual (O031)
4-2
Branch and Repetition
For conditional sentence “if({condition})”, the command(s) right after this sentence is executed when
the condition is TRUE. If the left brace ({) is found right after this conditional sentence, all the subse-
quent commands to the right brace (}) are executed in accordance with the condition.
If the “else” statement follows the command right after the “if({condition})” sentence or the command set
enclosed by braces, the command or command set enclosed by braces right after the “else” statement
are executed when “if” statement is FALSE. The “else” statement may be omitted.
For “switch({expression})” conditional sentence, the value of the expression is evaluated and the value
is truncated to an integer value if necessary. If a “case” conditional sentence that specifies the matching
integer is found, the program execution moves to that “case” conditional sentence. The execution con-
tinues until “break” statement is found. It also continues if a subsequent “case” branch is found. “break”
statement makes the execution jump to a program command following the end line of the whole
“switch” conditional description.
If “break” statement is not written after the “case” branch, the execution continues until the whole
“switch” conditional description ends, then proceeds to the following commands. If no “case” conditional
sentence is found that matches the evaluated value of the “switch” expression, the program execution
jumps to the “default” branch. If the “default” branch is not found, the execution jumps to a program
command right after the end of the whole “switch” conditional description.
For conditional sentence “while({condition})”, the command(s) right after this sentence is executed
when the condition is TRUE. If the left brace ({) is not found right after this conditional sentence, the
program is executed when only one of the subsequent commands is TRUE.
If the left brace ({) is found right after this conditional sentence, the program is executed when all the
subsequent commands to the right brace (}) are TRUE. When the execution of a command or com-
mand set enclosed by braces is completed, the process automatically returns to the “while” conditional
sentence, and the loop ends.
When the condition of the “while” statement is FALSE, the execution skips the command right after the
“while” conditional sentence or command set enclosed by braces, and jumps to a command right after
it.
For conditional sentence “do..while({condition})”, the command right after the “do” statement or com-
mand set enclosed by braces is always executed once. When the condition of the “while” statement
after this command or command set is TRUE, the execution returns to the “do” statement, and the loop
ends. When the condition is FALSE, the execution continues the following command.
4-2-1
if/else
4-2-2
switch/case
4-2-3
while
4-2-4
do/while
Содержание NJ501-5300
Страница 13: ...11 CONTENTS NJ NY series G code Instructions Reference Manual O031...
Страница 28: ...Revision History 26 NJ NY series G code Instructions Reference Manual O031...
Страница 38: ...1 Basic Information on NC Programming 1 10 NJ NY series G code Instructions Reference Manual O031...
Страница 40: ...2 G Code 2 2 NJ NY series G code Instructions Reference Manual O031...
Страница 53: ...2 15 NJ NY series G code Instructions Reference Manual O031 2 Dwell Instruction Name Page G04 Dwell P 2 16...
Страница 72: ...2 G Code 2 34 NJ NY series G code Instructions Reference Manual O031...
Страница 108: ...3 M Code 3 2 NJ NY series G code Instructions Reference Manual O031...
Страница 112: ...3 M Code 3 6 NJ NY series G code Instructions Reference Manual O031...
Страница 124: ...3 M Code 3 18 NJ NY series G code Instructions Reference Manual O031...
Страница 128: ...3 M Code 3 22 NJ NY series G code Instructions Reference Manual O031...
Страница 136: ...4 PROGRAM CODES 4 8 NJ NY series G code Instructions Reference Manual O031...
Страница 141: ......