6-87
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-5 Programming Languages
6
6-5-3 Structured Text Language
Process Flow Diagram:
Application:
Use this construct to perform one of two processes depending on evaluation of a condition (condi-
tion expression).
Description:
If <condition_expression> is TRUE, <statement_1> is executed.
If <condition_expression> is FALSE, <statement_2> is executed.
Precautions:
• IF must always be used together with END_IF.
• Write a statement that evaluates to TRUE or FALSE (for example IF A>10) or a BOOL variable (for
example IF A) for the condition expression.
• You can write <statement_1> and <statement_2> on multiple lines. Separate statements with a
semicolon (;).
Example: Another IF Statement before <statement_1>
Process Flow Diagram:
ELSE corresponds to the previous THEN statement, as shown above.
• You can execute more than one statement for both <statement_1> and <statement_2>. Separate
statements with a semicolon (;).
IF <condition_expression_1> THEN
IF <condition_expression_2> THEN
<statement_1>;
ELSE
<statement_2>;
END_IF;
END_IF;
Condition
expression
Statement 1
FALSE
TRUE
Statement 2
Condition
expression 1
Statement 1
FALSE
TRUE
Statement 2
Condition
expression 2
TRUE
FALSE