13: S
CRIPTS
13-20
S
MART
AXIS P
RO
/L
ITE
U
SER
'
S
M
ANUAL
FT9Y-B1378
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;
}
}
Содержание FT1A-B12RA
Страница 1: ...FT9Y B1378 5 ...
Страница 2: ......
Страница 208: ...7 DEVICE ADDRESSES 7 16 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 ...
Страница 226: ...8 INSTRUCTIONS FUNCTION BLOCKS REFERENCE 8 18 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 ...
Страница 340: ...13 SCRIPTS 13 36 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 ...
Страница 384: ...APPENDIX A 18 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 European Font ISO 8859 1 Cyrillic Font ANSI 1251 ...
Страница 385: ...SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 A 19 APPENDIX Japanese Font JIS X0201 ...
Страница 386: ...APPENDIX A 20 SMARTAXIS PRO LITE USER S MANUAL FT9Y B1378 ...