Introduction

Compare blocks are only available in the LD programming language. They are used to execute a compare expression (<, >, <=, >=, =, <>) in the ST programming language.

NOTE: The same functionality is also possible using ST expressions.

If the state of the left link is 1 and the result of the comparison is 1, the state of the right link is 1.

Compare blocks can be placed in any free cell except the last cell directly on the right power rail.

A compare block requires 1 line and 2 columns.

If a compare block is placed in a cell that is occupied by a Boolean link, and the following cell is either empty or also occupied by a Boolean link, then these cells will be occupied by the placed compare block.

If a compare block is placed in a cell, and this cell or the following cell is already occupied by another object, an error message is returned.

NOTE: The above behavior maybe different when Insert Mode is activated.

A placed compare block automatically creates a connection with its neighboring objects on the left and right if they are of the BOOL data type and there are no free cells between them.

Activating compare block placement mode

You have the following options to activate the compare block placement mode:

  • Use the Objects > Compare Block menu command.

  • Use the Edit > New > Compare Block menu command.

  • Use the Common Objects > Compare Block menu command from the shortcut menu.

  • Press the Ctrl+F7 key combination.

    or

  • Choose the symbol.

The active compare block placement mode is indicated by the cursor symbol.

Note

In the Tools > Options dialog box on the Data and Languages > Languages tab, if the Automatically assign a variable to a new graphical object checkbox is selected, then the corresponding properties dialog box is automatically opened when an object is placed. The procedures explained here are used when the checkbox is cleared.

Placing a compare block

Placing a compare block:

Step

Action

1

Activate the compare block placement mode.

2

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 compare blocks is placed.

3

Placing other compare blocks:

  • 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.

Defining the compare operation

Defining the compare operation:

Step

Action

1

Open the properties dialog box for the compare block.

Result: The properties dialog box for the compare block is opened.

2

Enter the desired compare operation in the text box, see also General tab.

Example:

3

Confirm the compare operation with OK.

Result:

  • If the selected variables are declared, they are enabled in the section. A syntax and semantics check is performed and the procedure ends here.

  • If the more than one of the selected variables are not declared, they are enabled in the section but not declared. A syntax and semantics check is performed. Declare them at this time, using the data editor.

  • If the one of the selected variables is not declared, a variable declaration dialog box opens. In this case, continue with the following steps of this procedure.

    Variable declaration dialog box

    Note: If you wish to declare the variable later, close the dialog box using the symbol. In this case, the variable name is enabled in the section, but not declared.

4

If you do not want to assign the variable an address or comment, confirm using Enter or the symbol.

Result: The variable is declared and enabled in the section. A syntax and semantics check is performed and the procedure ends here.

Example:

5

If you do want to assign the variable an address and/or comment, use the symbol for obtaining an advanced dialog and enter the address and/or comment.

6

Confirm with Enter or the symbol.

Result:The variable is declared and enabled in the section. A syntax and semantics check is performed.

Example: