6 - 17
6 DriveProgramming Commands
DriveProgramming User’s Manual (I622-E1)
6-4 Program Control Commands
6
Example
Select/Case/Case Else/EndSelect
Command Description Argument
Allows the execution of multiple program sections
depending on the variable value. Executes <com-
mand set n> when <condition variable> matches
<condition value n> of any “case” command.
Executes <command set for others> (“case
else”) when <condition variable> does not
match any of condition values of the “case”
commands.
This command is useful when you need to
select among multiple options based on a <con-
dition variable>.
This command is also useful to organize pro-
grams when it is used with the “call” commands
that calls subroutines.
Condition variable
: a condition variable you use
Condition value n: any variable or constant
(range −128 to 127)
Command set n: one or more commands until
next “case” or “endselect” command. It can con-
tain nested commands (up to eight levels).
Format
Flowchart method Text language method
select <condition variable>
case <condition value 1>
<command set 1>
…
case <condition value n>
<command set n>
…
case else
<command set for others>
endselect
Note A "select” is counted as nesting level 1.
A set of "select” to “endselect” used in a subroutine is counted as nesting level 2.
Flowchart Text
Block number
Operation
1 to 8
Based on the value of U(00), 100 is assigned to U(01) if U(00) is 1, and 200 is assigned to U(01) if U(00)
is 2. In the case 3, 500 is assigned to U(01) and the program jumps to the “endselect” command.
9 Jumps to the block 1: loop_ unconditionally.