Functions

Define functions in the
Functions
section of the device in the
Application View
.
For functions, specify these properties
Property
Description
Comment
Plain text
Description
Rich text
Language
(Read-only) Programming language of the program organization unit (POU)
Name
Name of the function. Function names are limited to eight (8) characters beginning with a letter or single underscore followed by letters, digits, and single underscores. Names cannot be reserved words, defined words, or data types. Use unique names for POUs within a project.
Type
(Read-only) Type of POU. Possible values are program, user-defined function, or user-defined function block
Perform these tasks for functions:
Task
Procedure
Add a function
  1. In the
    Application View
    , right-click the
    Functions
    element, point to
    Add Functions
    , and then click the required programming language for the function.
  2. To define the parameters for the function, right-click the function, and then click
    Parameters
    .
Set properties for a function
In the
Application View
, right-click the function, and then click
Properties
.
Copy and paste a function
Copying and pasting a function includes local variables and local defined words.
  1. In the
    Application View
    , right-click the function, and then click
    Copy
    .
  2. Right-click the
    Functions
    element, and then click
    Paste
    .
    TIP: POU comments are not copied during a copy and paste operation.
Delete a function
In the
Application View
, right-click the function, and then click
Delete
.
TIP: When deleting a function, save the project before making subsequent changes.
Rename a function
In the
Application View
, right-click the function, then click
Rename
, and then type a name for the function.
TIP: When adding functions, define parameters. Functions can have a maximum of 32 parameters (31 inputs and one output). When defining parameters, consider these limitations:
  • Parameter names are limited to 32 characters and must begin with a letter or single underscore followed by letters, digits, and single underscores. Do not use reserved words, defined words, or data types for names. Use unique names for the parameters of a function.
  • Possible data types for parameters are BOOL, DINT, REAL, TIME, MESSAGE
  • For Message type variables, string capacity is limited to 255 characters
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal