For each line in list

Command groupFlag affectedReversibleExecute on clientPlatform(s)
ConstructsNONONOAll

Syntax

For each line in list
 
 ([
Selected lines only
][,
Descending
])
 
from
 
start
 
to
 
stop
 
step
 
step

Options

Selected lines onlyIf specified,the for loop only operates on the selected lines in the list
DescendingIf specified,the for loop steps through the list from the largest line number to the smallest line number

Description

This command marks the beginning of a loop that processes the lines of the current list. You must specify the current list before executing the For loop. The For loop is a convenient way to write While/ End While loops to step through each line of a list. With the Selected lines only option, the loop will skip over any lines encountered that are not selected.

The Start value specifies the line in the list at which method execution of the For loop starts. The loop continues until the processed line exceeds or is equal to the Stop value. If the Step value is not specified, the default value of 1 is used. The values involved must all be integers. The Descending option tells Omnis to step through the list from a high line number to a low line number. The Start and Stop values are swapped if the Stop value is less than the Start value.

You can use Jump to start of loop within the loop to continue the next iteration of the loop. Similarly, Break to end of loop will exit the loop prematurely.

For each line in list operates on the current list. The matching End For will also operate on the current list. Unpredictable behavior will result if the current list is changed and not restored within the For/ End For construct.

Example

Prepare for print
 

Set current list
 
iMyList

For each line in list
 
from
 
1
 
to
 
iMyList
.
$linecount
 
step
 
1

  
Load from list
 

  
Print record
 

End For
End print
 

 
# this is equivalent to the method below

Prepare for print
 

Set current list
 
iMyList

Calculate
 
iMyList
.
$line
 as 
1

While
 
iMyList
.
$line
<=
iMyList
.
$linecount

  
Load from list
 

  
Print record
 

  
Calculate
 
iMyList
.
$line
 as 
iMyList
.
$line
+1

End While
End print