155
Structured Text (ST Language) Specifications
Appendix B
Note
(1) The
condition
can also be specified as a boolean variable (BOOL data type) only rather than an
equation.
(2) Even if the
condition
equation is true before the
expression
has been executed, the
expression
will
be executed.
Example
Processing is repeated from when variable n = 1 until 50 in increments of 1 and n is added to array variable
DATA[n]. If DATA[n] exceeds 100, however, processing will end.
FOR n:=1; TO 50 BY 1 DO
DATA[n]:=DATA[n]+n;
IF DATA[n]>100 THEN EXIT;
END_IF;
END_FOR;
RETURN Statement
Summary
This statement is used to execute the next instruction following the location that called the function block in the
program when the function block in the structured text must be forced to end before it has been completed.
Reserved Words
RETURN
Statement Syntax
RETURN;
Usage
Use the RETURN statement when a function block has been forced to end.
Examples of Structured Text Programming
Example 1: Conversion of BCD Data (#0000-#9999) to BIN Data
(*Check the input parameter "Input_BCD" (BCD data) *)
IF (Input_BCD>=0 & Input_BCD<=16#9999) THEN
ENO:=true;
ELSE
ENO:=false;
RETURN;
END_IF;
(*BCD data is divided by 16 four times to get each digit of the BIN data converted from the BCD data*)
DIV_1:=Input_BCD/16;
DIV_2:=DIV_1/16;
DIV_3:=DIV_2/16;
DIV_4:=DIV_3/16;
(*Calculate each digit of the BIN data converted from the BCD data*)
BIN_1:=Input_BCD-16*DIV_1;
(*a number of 16
0
digit*)
BIN_2:=DIV_1-16*DIV_2;
(*a number of 16
1
digit*)
BIN_3:=DIV_2-16*DIV_3;
(*a number of 16
2
digit*)
BIN_4:=DIV_3-16*DIV_4;
(*a number of 16
3
digit*)
(*Calculate the BIN data "Output_BIN" (output parameter) *)
Output_BIN:=BIN_1+BIN_2*10+BIN_3*10*10+BIN_4*10*10*10;
Input_BCD Output_BIN
Содержание CS1-H Series
Страница 3: ...iv...
Страница 5: ...vi...
Страница 7: ...viii TABLE OF CONTENTS...
Страница 15: ...xvi Application Precautions 4...
Страница 151: ...136 Procedures Section 3 2...
Страница 153: ...138 Data Types Appendix A...
Страница 177: ...162 External Variables Appendix C...
Страница 181: ...166 Revision History...