13: S
CRIPTS
13-18
S
MART
AXIS P
RO
/ L
ITE
U
SER
'
S
M
ANUAL
FT9Y-B1378
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.
Содержание SmartAXIS FT9Z-1A01
Страница 1: ...FT9Y B1378 7...
Страница 10: ...TABLE OF CONTENTS Preface 9 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378...
Страница 212: ...7 DEVICE ADDRESSES 7 16 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378...
Страница 230: ...8 INSTRUCTIONS FUNCTION BLOCKS REFERENCE 8 18 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378...
Страница 344: ...13 SCRIPTS 13 36 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378...
Страница 385: ...SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 Appendix 15 APPENDIX European Font ISO 8859 1 Cyrillic Font ANSI 1251...
Страница 386: ...APPENDIX Appendix 16 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 Japanese Font JIS X0201...
Страница 393: ......