Creating a User Function
Step | Action |
---|---|
1 | Create or Open your project. |
2 |
In the Project window panel locate the User Function/Function Block section.
|
3 | Right-click on the User Function/Function Block section. Select Add Item è Function… |
4 |
Enter information for your function in the window that pops up.
|
5 |
Give your function a descriptive name.
|
6 |
Choose the language of the function’s code.
|
7 |
Select or de-select the Use EN/ENO option.
|
8 |
Choose a Return data type.
|
9 |
Choose a value for Width (Columns).
|
10 |
Add a Program Description to let other users know what the function does.
|
11 |
Select Password tab to add security options to your Function. Using the password function is optional.
|
12 |
Use New password section to password protect your function. This step is optional.
|
13 |
Enable or disable Protect program check box. This step is optional.
|
14 |
Open the Local Variables file for your function.
Note: A pre-created return variable will be added automatically when creating a function. |
15 | Add Local Variables to your function. |
16 |
Choose Variable Kind for your local variable.
Variable Kind Definitions:
|
17 |
Enter a name for your variable in the Variable column.
|
18 |
Choose the data type of your variable in the Type column.
Available data types:
|
19 |
Used check box is checked if variable is used in the code.
|
20 |
Add a comment to the variable to let other users know what the variable is used for.
|
21 |
Open function Program to add code.
Note: The value type set to the return variable in the function code must match the type defined when creating a function. An error will be generated at Check Program if there is an issue. |
22 |
After adding Function code, press Check Program to check your function for errors.
|
23 |
Fix any errors that appear or proceed to next section to start using your function.
|
LM121-1