![Fuji Electric SPF Series Скачать руководство пользователя страница 68](http://html1.mh-extra.com/html/fuji-electric/spf-series/spf-series_user-manual_2341814068.webp)
1-59
Section 1 Specifications
1) Function
A function is a program organization unit that, when executed, generates a single data item, including multiple elements such as
an array or structure).
A function has no internal state, that is, executions of a function with the same input parameters always generate the same
output. Predefined functions can be used in other programs, functions, and function blocks.
The value of variables that are used only within a function are unpredictable when the function is called.
2) Function block
A function block is a program organization unit that, when executed, generates one or more data items. A function block can
have two or more copies of data which are called instances. Each instance is given an identifier called the instance name. An
instance has output, internal, and input variables.
Some of the output and internal variables must retain their contents until the function block is called next time. Consequently, a
function block does not always generate the same output even when it is called multiple times with the same input parameters.
The program that calls a function block can access only the input and output variables of the function block; it can access none
of the internal variables of the function block.
Predefined function blocks can be used within a program or function block.
The instances of a function block can be referenced only within the program organization unit in which they are declared unless
the instances are declared globally.
PG
VAR
A:INT;
B:INT;
C:INT;
D:INT;
END_VAR
A:=AAA(B,C);
D:=AAA(B,C);
FCT
Function name: AAA
VAR_INPUT
IN1:INT;
IN2:INT;
END_VAR
VAR
TEMP:INT;
END_VAR
TEMP:=IN1;
TEMP:=TEMP+IN2;
AAA:=TEMP;
RET
The value is unpredictable
when the function is called.
The variables in FCT are initialized
when FCT is called.
The output value is assigned
to the FCT name.