Introduction

The subroutine to be called must be located in the same task as the section calling.

Subroutines can also be called from within subroutines.

Subroutine calls are expansions to IEC 61131-3 and must be explicitly enabled via the Tools > Project Settings dialog box, in the Language extensions tab by activating the Allow subroutines check box.

In IL, a subroutine call consists of the CAL operator, followed by the name of the subroutine section, followed by an empty parameter list (optional), e.g.

CAL SR_Name

or

CAL SR_Name ()

In ST, a subroutine call consists of the name of the subroutine section, followed by an empty parameter list, followed by a semicolon, e.g.

SR_Name () ;

The name of subroutine is shown in boldface to identify that these subroutines can be refined.

You can enter the name of the subroutine section just like any other text, or use the input assistant.

Entering the name of the subroutine section with input assistant

Process the following steps to enter a subroutine section name with the input assistant:

Step

Action

1

Place the cursor at the target position.

2

Use the Edit > New > Select subroutine menu command.

or

Select the symbol.

Result:

A selection dialog box for selecting the subroutine to be called is opened.

3

Click the symbol, select the subroutine to be called from the list and confirm pressing Enter.

Note: The subroutine to be called must be located in the same task as the section calling.

Result: The name of the subroutine section is enabled in the section.

4

Complete the subroutine call.

IL example:

ST example: