Syntax for calls:
<return value variable> := <POU name> . <method name> ( <argument passing> );
<return value variable> |
Variable for the return value The type has to match the return type of the method. Note: In the case of methods which do not have an explicit return type, the first declared output is used as the return value. A method does not return a value only if neither the return type nor the output are declared. However, a compiler error is not generated in either case. |
<POU name> |
Identifier of the function block instance under which the method is arranged |
<method name> |
Identifiers of methods |
<argument passing> |
Comma-delimited list with the actual arguments One argument is passed to each parameter (variable) of the method: <parameter name> := <actual argument>
|
Example
Declaration
METHOD PUBLIC DoIt : BOOL VAR_INPUT iInput_1 : DWORD; iInput_2 : DWORD; sInput_3 : STRING(12); END_VAR
Call with passing an argument to a parameter
bFinishedMethod := fbInstance.DoIt(sInput_3 := 'Hello World ', iInput_2 := 16#FFFF, iInput_1 := 16);
When the method is called, the return value of the method is assigned to a locally declared variable.
Example
If you omit the names of the input variables, then the assignment of the arguments results from the declaration order.
Declaration
METHOD PUBLIC DoIt : BOOL VAR_INPUT iInput_1 : DWORD; iInput_2 : DWORD; sInput_3 : STRING(12); END_VAR IF iInput_1 = iInput_2 THEN DoIt := TRUE; // explicit return value END_IF
Call with passing an argument according to the order in the declaration
bFinishedMethod := fbInstance.DoIt( 16, 16#0010,'Hello World ');