beautypg.com

Delta RMC151 User Manual

Page 258

background image

RMC70/150 and RMCTools User Manual

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

Input/Output

e. Click OK.

To adjust the order of the parameters, use the Up and Down

arrows. To

delete parameters, use the Delete

button.

6. Click OK.
7. The new function will be added to the User Functions list, and will appear in the editor.

Editing a User Function

User Function Description
The initial comment in the user function is the function description, enclosed by green

parentheses with an asterisk:

(* *)

. This description will appear when browsing the

functions in the Expression Editor.
Enter a description that describes what the function does. It is good practice to clearly

describe the parameters and return value. You do not need to describe the parameter

data types, as this is automatically displayed in the Expression Editor.
Function Name
The function name and return data type is defined by the keyword FUNCTION. To

change the function name or data type, change the text following the FUNCTION

keyword. The entire function must also end with the END_FUNCTION keyword.
For example, mm2inch is this function's name, which returns a value of type REAL:

FUNCTION

mm2inch

: REAL

238

Delta Computer Systems, Inc.

This manual is related to the following products: