beautypg.com

Delta RMC151 User Manual

Page 385

background image

5 Programming

All user functions in the project are displayed in the User Function list. To add a user
function, click the New User Function button. To delete a user function, click the
Delete User Function button.
User Functions Folders
User functions can be organized into folders in the user function list.

1. To create a new folder, click the New Folder button on the toolbar. Type the

folder name and press Enter.

2. To add new functions to the folder, select the folder, then click the New User

Function button. You can also drag existing functions into the folder with the

mouse.

Click the Delete Folder button to delete a folder and it contents.
Importing User Functions

1. Right-click in the function list pane and choose Import User Functions.
2. Browse for the user function file of type .rmcflib and click Open.
3. The user functions available in the .rmcflib file will be listed. Check the desired

functions in the file to import. The Select All and Clear All buttons may assist you.

Imported functions cannot have the same name as a user function already in the

project. These functions are labeled (duplicate). Use the Rename button to rename

a function in the import list so that it can be imported.

4. After selecting the desired user functions to import, click OK.

Exporting User Functions

1. Right-click in the function list pane and choose Export User Functions.
2. Choose the functions to export, then click OK.
3. Browse to the desired location, enter a filename, then click Save.

Calling User Functions

To insert a user function into an expression:

1. Begin typing the name of the function and choose the function from the pop-up list.

Or, browse for the function on the Function tab of the Expression Editor and double-

click it.

2. Type an opening parenthesis. A pop-up window will open, listing the required

parameters for your convenience.

3. Make sure to enter all required parameters, separated with a comma.
4. Type a closing parenthesis.

Using the Function's Return Value
Typically, when calling a user function, the function's return value is assigned to some

register. For example, the return value of the user function

inch2mm

is assigned to the

variable

MyPos

here:

MyPos

:=

inch2mm

(

_Axis[0].ActPos

);

A user function can also be called without assigning the function's result to a register.

This is useful when the function has output parameters. For example, consider the

following user function that converts polar coordinates (radius and angle) to cartesian

coordinates (x and y). The function has two input parameters and two output

parameters:

BOOL Polar2Cart( [in] REAL radius, [in] REAL angle, [out] REAL x, [out] REAL y)

This user function can be used in an expression as follows:

Polar2Cart

(

MyRadius

,

MyAngle

,

MyX

,

MyY

);

deltamotion.com

365

This manual is related to the following products: