FC6A S
ERIES
MICROS
MART
L
ADDER
P
ROGRAMMING
M
ANUAL
FC9Y-B1726
26-21
26: S
CRIPT
Example 1.8
Iteration
Script
Operation Description
While the value of D0100 is 0, the while statement is repeated.
Inside the while statement, if the values of D0102 and D0103 are equal, the while statement will terminate, and after [M0000]
changes to 1, execution breaks out of the while statement.
In the example script above, the values of D0102 and D0103 are equal when the while statement repeats twice, and after M0000
changes to 1, execution breaks out of the while statement loop. After execution, the value of D0100 is 0, the value of D0102 is 5,
the value of D0103 is 5, and M0000 is 1.
Example 1.9
Indirect write and indirect read using iteration (while statement)
Script
Operation Description
[D0100] = 0;
[D0102] = 3;
[D0103] = 5;
while ([D0100] == 0)
{
[D0102] = [D0102] + 1;
if ([D0103] == [D0102])
{
SET([M0000]);
break;
}
}
//Transfer D0010 through D0019 to D0100 through D0109
// Initialize the offset value
[D0000] = 0;
// Loop ten times
while ([D0000] < 10)
{
// Transfer 1 word by indirect assignment
OFFSET([D0100] , [D0000]) = OFFSET([D0010] , [D0000]);
// Increment indirect value
[D0000] = [D0000] + 1;
}
This script stores the values of D0010 through D0019 in D0100 through D0109.
It operates as follows.
First, the offset value D0000 is initialized and set to 0.
First iteration (loop)
: The value of D0000 is 0, so the condition "[D0000] < 10" is true and the statements inside while are executed.
• The value of D0010, 0 words from D0010, is stored in D0100, 0 words from D0100.
• 1 is added to the value of offset value D0000, so that it becomes 1.
Second iteration (loop) : The value of D0000 is 1, so the condition "[D0000] < 10" is true and the statements inside while are executed.
• The value of D0011, 1 word from D0010, is stored in D0101, 1 word from D0100.
• 1 is added to the value of offset value D0000, so that it becomes 2.
:
(Repeats in the same manner for the third to ninth iterations)
:
Tenth iteration (loop) : The value of D0000 is 9, so the condition "[D0000] < 10" is true and the statements inside while are executed.
• The value of D0019, 9 words from D0010, is stored in D0109, 9 words from D0100.
• 1 is added to the value of offset value D0000, so that it becomes 10.
The value of D0000 is 10, so the condition "[D0000] < 10" is false and execution breaks out of the while loop.
After execution, the values of D0100 through D0109 are the same with the values of D0010 through D0019.
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 ...