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 |
0 | CMD0001 | No error | |
1 | CMD0202 | Syntax error | |
1 | SDP0118 | Command in false context | |
1 | SDP0223 | Incorrect environment | |
3 | CMD2203 | Incorrect syntax file | |
32 | CMD0221 | System error (internal error) | |
64 | SDP0091 | Semantic error (incorrect expression) | |
130 | SDP0099 | No 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.