The MANDATORY keyword is used in combination with input parameters to a function to support forced parameter.
By using the MANDATORY keyword it is enforced by the VPL compiler that the specified parameter must be assigned when the function is called.
This functionality can be used to ensure that a critical parameter is always assigned by the function caller.
Using the MANDATORY keyword excludes the possibility to assign a default value to the given parameter.
This is a simple example of using the MANDATORY keyword:
FUNCTION TEST;
VAR_INPUT
v1 : MANDATORY INT;
v2 : MANDATORY STRING;
v3 : INT := 17;
END_VAR;
END_FUNCTION;
The TEST function declares that v1 and v2 must always be assigned by the caller and v3 is optional and if not assigned it will contain the default value of 17.
|