Introduction

Every subroutine and every DFB (derived function block) is exited after being processed, i.e. you return to the main program called.

If the subroutine/DFB is left prematurely, the return to the main program can be forced by the return object.

If the status of the left link is ON, a return from the subroutine or DFB to the main program is performed.

Return objects can only be used in subroutines or DFBs. They cannot be used in main programs.

To generate a conditional return, a return object is placed at the end of a series of contacts.

Selecting the return object

You have the following options to select return objects:

  • Use the Edit > New > Return menu command.

  • Use the Common Objects > Return menu command from the shortcut menu.

    or

  • Choose the symbol.

The active placement mode for return objects is indicated by the cursor symbol.

Note

In the Tools > Options dialog box on the Data and Languages tab, if the Automatically assign a variable to a new graphical object check box is selected, then the corresponding properties dialog box is automatically opened when an object is placed. The procedure explained here is valid for deactivated check boxes.

Placing return objects:

Placing return objects:

Step

Action

1

Create a subroutine or a DFB in the LD programming language.

2

Create the logic for the subroutine/DFB.

3

Select the return object.

4

Click the target cell in the LD section.

or

Use the arrow keys to move the gray field to the target position and press Enter.

Result:The return object is inserted.

Example:

5

To insert further return objects:

  • Click the target cell in the LD section.

    or

    Use the arrow keys to move the gray field to the target position and press Enter.

  • To return to selection mode:

    Press the Esc key.

  • To insert other objects:

    Select the object you wish to insert.