beautypg.com

User functions – Delta RMC151 User Manual

Page 383

background image

5 Programming

a (REAL)
The input value.

Return Value

Returns a REAL.

Examples

TRUNC_REAL(34.78) returns 34.0
TRUNC_REAL(-3.46) returns -3.0
TRUNC_REAL(-3.99) returns -3.0

5.14.3. User Functions

5.14.3.1. User Functions

To access the User Function Editor: In the Project pane, expand Programming, and

double-click User Functions.

User functions are custom functions created or imported by the user. User Functions provide

flexibility and efficiency for advanced applications. Most applications do not need user

functions. User functions can be used anywhere expressions are used in the RMC, including

the Expression (113) command, link conditions in user programs, and the Program Triggers.
User functions can have any number of parameters, and return a single value as the result.

The parameters can be input, output, or input/output types. Therefore, a function can return

many values via the output or input/output type parameters.

Example User Functions

See the Example User Functions for examples that you can copy and paste into your project.

Creating a User Function

1. In the Project Pane, expand Programming and double-click User Functions.
2. In the User Function Editor toolbar, click the New User Function button.
3. In the New User Function dialog, type a Name for the function.
4. Choose the desired Return Data Type. This is the data type of the resulting value

returned by the function.

5. Add Parameters (optional)

Do the following for each parameter you wish to add. Parameters appear as Input,

Output, and Input/Output variables in the user function. Parameters can also be added

and modified later when editing the user function, as described in Declaring Variables

in User Functions.

a. Click the Add button.
b. Type a Name for the function.
c. Choose the desired Data Type of the parameter. To create an array parameter, set

the Size parameter to a value greater than 1.
d. In the Input/Output box, choose the parameter type:

Input

Output

deltamotion.com

363

This manual is related to the following products: