IDEC FT1A Series User Manual page 322

Hide thumbs Also See for FT1A Series:
Table of Contents

Advertisement

13: S
CRIPTS
Example 1.8
Iteration
Script
[D0100] = 0;
[D0102] = 3;
[D0103] = 5;
while ([D0100] == 0)
{
[D0102] = [D0102] + 1;
if ([D0103] == [D0102])
{
SET([M0000]);
break;
}
}
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
//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
}
Operation Description
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.
13-18
S
AXIS P
/L
U
'
MART
RO
ITE
SER
S
M
FT9Y-B1378
ANUAL

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents