
FC6A S
ERIES
MICROS
MART
L
ADDER
P
ROGRAMMING
M
ANUAL
FC9Y-B1726
26-23
26: S
CRIPT
Example 1.12
Conditional branch with switch using the default statement
Script
Operation Description
If the value of D0100 is 0, then 0x1234 is stored in D0102.
If the value of D0100 is 1, then 0x5678 is stored in D0102.
If the value of D0100 is not 0 nor 1, then 0x9999 is stored in D0102.
Example 1.13
Terminate the script with the return statement
Script
Operation Description
If the value of D0100 is not 0x1234, then 0 is stored in D0103.
If the value of D0100 is 0x1234, then 0x5678 is stored in D0102 and the script is terminated.
The return statement does not break out of a loop like the break statement, it terminates the script execution.
Example 1.14
Break out of a loop with the break statement
Script
Operation Description
While the value of D0100 is 0, the while statement is repeated until D0102 and D0103 match.
Inside the while statement, if the values of D0102 and D0103 are equal, the while statement will end and execution breaks out of
the while statement.
In the example above, the values of D0102 and D0103 match when the while statement is repeated twice, and after D0000.01
changes to 1, the while statement ends. After execution, the value of D0100 is 0, the value of D0102 is 5, the value of D0103 is 5,
and the value of D0000.01 is 1.
switch ([D0100])
{
case 0:
[D0102] = 0x1234;
break;
case 1:
[D0102] = 0x5678;
break;
default:
[D0102] = 0x9999;
break;
}
if (0x1234 == [D0100])
{
[D0102] = 0x5678;
return;
}
[D0103] = 0;
[D0100] = 0;
[D0102] = 3;
[D0103] = 5;
while ([D0100] == 0)
{
[D0102] = [D0102] + 1;
if ([D0102] == [D0103])
{
SET([D0000.01]);
break;
}
}
Summary of Contents for MICROSmart FC6A Series
Page 1: ...B 1726 7 FC6A SERIES Ladder Programming Manual ...
Page 8: ...Preface 7 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 32: ...1 OPERATION BASICS 1 20 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 96: ...3 INSTRUCTIONS REFERENCE 3 18 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 130: ...4 BASIC INSTRUCTIONS 4 34 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 192: ...9 SHIFT ROTATE INSTRUCTIONS 9 12 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 272: ...12 DISPLAY INSTRUCTIONS 12 24 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 284: ...14 REFRESH INSTRUCTIONS 14 6 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 502: ...25 DATA LOG INSTRUCTIONS 25 22 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 546: ...26 SCRIPT 26 44 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...
Page 598: ...APPENDIX A 14 FC6A SERIES MICROSMART LADDER PROGRAMMING MANUAL FC9Y B1726 ...