Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

CYCLE Terminate loop pass

&pagelevel(4)&pagelevel

Domain: PROCEDURE

Command description

The CYCLE command can be called in loop blocks (FOR, WHILE, REPEAT block). It then terminates the current loop pass and resumes procedure execution by executing the terminating command in the loop block (END-FOR, END-WHILE, UNTIL). The loop condition is then rechecked and, if necessary, the next loop pass started (see also section “Branch toend of loop” (Branch to end of loop )).

Execution of the CYCLE command can be made subject to a condition.

Format

CYCLE

BLOCK = *LAST / *ALL / <structured-name 1..255>

,CONDITION = *NONE / <text 1..1800 with-low bool-expr>

Operands

BLOCK =
Designates the loop or loop block.

BLOCK = *LAST
Designates the next higher loop block; procedure execution is continued with the next loop terminating command.

BLOCK = *ALL
In the event of nested loops, designates the outermost loop block; procedure execution is continued with the last loop terminating command.

BLOCK = <structured-name 1..255>
Name of the loop to be terminated; the loop name is equivalent to the tag in the command call for the loop starting command.

CONDITION =
Defines a condition for execution of the CYCLE command.

CONDITION = *NONE
Command execution is not subject to any condition.

CONDITION = <text 1..1800 with-low bool-expr>
The CYCLE command is not executed unless the specified Boolean expression is “TRUE”.

Command return codes

(SC2)

SC1

Maincode

Meaning


0CMD0001No error

1CMD0202Syntax error

1SDP0118Command in false context

1SDP0223Incorrect environment

3CMD2203Incorrect syntax file

32CMD0221System error (internal error)

64SDP0091Semantic error (incorrect expression)

130SDP0099No further address space available

Example

Example 1

/LOOP: WHILE (COND < 9)
:
:
/IF (INP='*SKIP')
/WR-TEXT 'Element is skipped'
/CYCLE BLOCK=LOOP
/END-IF
:
:
/END-WHILE       "This command is executed after CYCLE" 

Example 2

/J=0
/FOR I=(’line 1’,’line 2’,’line 3’,’line 4)
/J=J+1
/CYCLE BLOCK=*LAST,CONDITION=(J=3)
/SHOW-VARIABLE I
/END-FOR

Output:

I = line 1
I = line 2
I = line 4

The third list element (I=3) is not evaluated, i.e. execution of the loop is terminated and execution of the procedure continues at END-FOR.