7.3.6
Passing parameters to blocks
Function Blocks (FB) and Functions (FC) have three different interface types:
● IN
● IN/OUT
● OUT
FBs and FCs receive parameters through the IN and IN/OUT interface types. The blocks
process the parameters and return values to the caller through the IN/OUT and OUT
interface types.
The user program transfers parameters using one of two methods.
Call-by-value
When the user program passes a parameter to a function as "call-by-value", the user
program copies the actual parameter value into the input parameter of the block for the IN
interface type. This operation requires additional memory for the copied value.
When the user program calls the block, it copies the values.
Call-by-reference
When the user program passes a parameter to a function as "call-by-reference", the user
program references the address of the actual parameter for the IN/OUT interface type and
does not copy the value. This operation does not require additional memory.
When the user program calls the block, it references the address of the actual parameters.
Note
Generally, use the IN/OUT interface type for structured tags (for example, ARRAY,
STRUCT, and STRING) in order to avoid increasing the required data memory
unnecessarily.
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
Programming concepts
7.3 Using blocks to structure your program
195