Mitsubishi Electric MELSEC iQ-F FX5 Programming Manual page 45

Program design
Hide thumbs Also See for MELSEC iQ-F FX5:
Table of Contents

Advertisement

Syntax
Format
CASE <Integer expression> OF
■CASE
<Integer selection 1> :
<Statement 1> ;
<Integer selection 2> :
<Statement 2> ;
<Integer selection n> :
<Statement n> ;
ELSE
<Statement n+1> ;
END_CASE;
Iteration statement
Syntax
Format
FOR <Repeat variable initialization>
■FOR
TO <Last value>
BY <Incremental expression> DO
<Statement> ;
END_FOR;
WHILE <Boolean expression> DO
■WHILE
<Statement> ;
END_WHILE;
REPEAT
■REPEAT
<Statement> ;
UNTIL <Boolean expression>
END_REPEAT;
EXIT;
■EXIT
Description
When the statement that has the integer selection value that
matches with the value of the integer expression (conditional
expression) is executed, and if no integer selection value
matches with the expression value, the statement that follows
the ELSE statement is executed.
The CASE statement is used to execute a conditional statement
based on a single integer value or an integer value as the result
of a complicated expression.
Description
The FOR...DO statement first initializes the data used as a
repeat variable.
An addition or subtraction is made to the initialized repeat
variable according to the incremental expression. One or more
statements from DO to END_FOR are repeatedly executed until
the final value is exceeded.
The repeat variable at the end of the FOR...DO syntax is the
value at end of the execution.
The WHILE...DO statement executes one or more statements
while the value of Boolean expression (conditional expression)
is TRUE.
The Boolean expression is evaluated before the execution of
the statement. If the value of Boolean expression is FALSE, the
statement in the WHILE...DO statement is not executed. Since
a return result of the Boolean expression in the WHILE
statement requires only TRUE or FALSE, any Boolean
expression that can be specified in the IF conditional statement
can be used.
The REPEAT...UNTIL statement executes one or more
statements while the value of Boolean expression (conditional
expression) is FALSE.
The Boolean expression is evaluated after the execution of the
statement. If the value of Boolean expression is TRUE, the
statement in the REPEAT...UNTIL statement are not executed.
Since a return result of the Boolean expression in the REPEAT
statement requires only TRUE or FALSE, any Boolean
expression that can be specified in the IF conditional statement
can be used.
The EXIT statement is used only in an iteration statement to
end the iteration statement in the middle of processing.
When the EXIT statement is reached during execution of the
iteration loop, the iteration loop processing after the EXIT
statement is not executed. The processing continues from the
line after the one where the iteration statement is ended.
Example
CASE
intV1
OF
1:
bool1:=TRUE;
2:
bool2:=TRUE;
ELSE
intV1:=intV1+1;
END_CASE;
Example
FOR
intV1:=0
TO
30
BY
1
DO
intV3:=intV1+1;
END_FOR;
6
WHILE
intV1=30
DO
intV1:=intV1+1;
END_WHILE;
REPEAT
intV1:=intV1+1;
UNTIL
intV1=30
END_REPEAT;
FOR
intV1:=0
TO
10
BY
1
DO
IF
intV1>10
THEN
EXIT;
END_IF;
END_FOR;
6 ST LANGUAGE
43
6.1 Configuration

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents