Introduction

You can call a statement (IF, FOR, WHILE, REPEAT, CASE) in the same way that you enter text (syntax, see section Statement in the Reference manual) or using an input assistant.

Selecting statements

Selecting statements:

Statement

Description

Call via menu command

Call via symbol

Call via key combination

IF

The IF statement determines that a statement or a group of statements will only be executed if its related Boolean expression has the value 1 (true). If the condition is 0, the statement or the statement group will not be executed.

See also in the Reference manual:

IF...THEN...END_IF,

ELSE and

ELSIF...THEN

Edit > New > IF Statement

F4

FOR,

The FOR statement repeats a statement sequence until the END_FOR statement. The number of repetitions is determined by the start value, the end value and the control variable.

See also in the Reference manual:

FOR...TO...BY...DO...END_FOR,

Edit > New > FOR Statement

F5

WHILE

The WHILE statement causes a sequence of statements to be executed repeatedly until its related Boolean expression is 0. If the expression is false right from the start, the group of statements will not be executed at all.

See also in the Reference manual:

WHILE...DO...END_WHILE,

Edit > New > WHILE Statement

F6

REPEAT

The REPEAT statement causes a sequence of statements to be executed repeatedly (at least once) until its related Boolean condition is 1.

See also in the Reference manual:

REPEAT...UNTIL...END_REPEAT,

Edit > New > REPEAT Statement

Shift + F6

CASE

The CASE statement consists of an INT data type expression (the "selector") and a list of statement groups. Each group is provided with a label which consists of one or several integer numbers (INT, DINT, UINT, UDINT) or areas of integer values. The first group of statements is executed, whose label contains the calculated value of the selector. Otherwise none of the statements will be executed.

See also in the Reference manual:

CASE...OF...END_CASE,

Edit > New > CASE Statement

Shift + F4

Calling a IF statement using the input assistant

Process the following steps to call a IF statement with the input assistant:

Step

Action

1

Place the cursor at the beginning of an empty line.

2

Select the input assistant for IF statements, see also Selecting statements.

Result:

An empty IF statement is inserted into the section.

3

Complete the IF statement with your data.

Result: A syntax and semantics check is performed immediately after the statement is entered.

Note: An input assistant is also provided for entering variables and calling FFBs (functions, function blocks and procedures).

For example:

Calling a FOR statement using the input assistant

Process the following steps to call a FOR statement with the input assistant:

Step

Action

1

Place the cursor at the beginning of an empty line.

2

Select the input assistant for FOR statements, see also Selecting statements.

Result:

An empty FOR statement is inserted into the section.

3

Complete the FOR statement with your data.

Result: A syntax and semantics check is performed immediately after the statement is entered.

Note: An input assistant is also provided for entering variables and calling FFBs (functions, function blocks and procedures).

For example:

Calling a WHILE statement using the input assistant

Process the following steps to call a WHILE statement with the input assistant:

Step

Action

1

Place the cursor at the beginning of an empty line.

2

Select the input assistant for WHILE statements, see also Selecting statements.

Result:

An empty WHILE statement is inserted into the section.

3

Complete the WHILE statement with your data.

Result: A syntax and semantics check is performed immediately after the statement is entered.

Note: An input assistant is also provided for entering variables and calling FFBs (functions, function blocks and procedures).

For example:

Calling a REPEAT statement using the input assistant

Process the following steps to call a REPEAT statement with the input assistant:

Step

Action

1

Place the cursor at the beginning of an empty line.

2

Select the input assistant for REPEAT statements, see also Selecting statements.

Result:

An empty REPEAT statement is inserted into the section.

3

Complete the REPEAT statement with your data.

Result: A syntax and semantics check is performed immediately after the statement is entered.

Note: An input assistant is also provided for entering variables and calling FFBs (functions, function blocks and procedures).

For example:

Calling a CASE statement using the input assistant

Process the following steps to call a CASE statement with the input assistant:

Step

Action

1

Place the cursor at the beginning of an empty line.

2

Select the input assistant for CASE statements, see also Selecting statements.

Result:

An empty CASE statement is inserted into the section.

3

Complete the CASE statement with your data.

Result: A syntax and semantics check is performed immediately after the statement is entered.

Note: An input assistant is also provided for entering variables and calling FFBs (functions, function blocks and procedures).

For example: