Declaring variables, In user functions, Declaring variables in user functions – Delta RMC151 User Manual
Page 386: Ee declaring variables in user functions
RMC70/150 and RMCTools User Manual
Limitations
The following limitations apply to calling user functions:
•
Any Output and Input/Output type parameters can only be step-local variables or
variables in the Variable Table. They cannot be system tags. If the result of the
function must go to a system tag, you can use a variable for the Output parameter,
then use a separate expression to assign the variable value to the system tag.
5.14.3.2. Declaring Variables and Parameters in User
Functions
Variables in user functions are used to assist in calculations, and/or serve as the function
parameters.
Variables as Parameters
Variables in a user function that are declared with the VAR_INPUT, VAR_OUTPUT, and
VAR_IN_OUT keywords make up the function's parameters. The order in which the
parameters are declared in the user function is the order in which the parameters must
be entered when calling that user function.
Input Parameters (VAR_INPUT)
Input parameters can only be read from. Values cannot be assigned to input parameters.
Output Parameters (VAR_OUTPUT)
Output parameters can only be assigned to. That is, output parameters can only be used
on the left-hand side of assignment expressions.
Input/Output Parameters (VAR_IN_OUT)
Input/output parameters can be read and written.
Variables as Local Variables
Variables declared with the VAR keyword are variables that can be used locally in the
user function to assist in calculations.
Declaring Variables and Parameters
Use the format in the example below to declare variables in user functions. Keep in mind
that the order in which the parameters (VAR_INPUT, VAR_OUTPUT, and VAR_IN_OUT)
are declared in the user function is the order in which the parameters must be entered
when calling that user function.
Variables can be of any data type, and can be fixed-length arrays.
Local variables (VAR), output parameters (VAR_OUTPUT), and input/output parameters
(VAR_IN_OUT) can optionally be initialized upon declaration.
Examples
VAR_INPUT
MyInputVar
: REAL;
MyOtherInputVar
: DINT;
YourVar
:
Array
[0..4]
OF
REAL;
END_VAR
VAR_IN_OUT
MyInOutVar
: REAL;
END_VAR
VAR_OUTPUT
366
Delta Computer Systems, Inc.