Please enable JavaScript to view this site.

ESL Documentation

Navigation: ESL Documentation > ESL Programmers Reference > Verbs

for each selected row/column loop

Scroll Prev Top Next More

Action Statement

Perform actions for rows/columns in a table object.

for each [selected] {row|column} VARIABLE of TABLE_NAME loop [LOOP_NAME]

    ACTION_STATEMENT ...

end loop [LOOP_NAME]

selected

Restrict the action statement(s) to the currently selected row(s)/column(s). If you omit this keyword, ESL performs all action statements on all row(s)/column(s).

VARIABLE

An integer variable that ESL will use to return the row or column position.

TABLE_NAME

The identifier for the table on which you want the action statement(s) performed.

LOOP_NAME

The identifier for a loop.

ACTION_STATEMENT

An action statement.

Description

This loop statement provides looping through table objects. You can nest for each row/column loops because you can provide VARIABLE as the iterator. The actions in the loop are repeated for each (selected) row/column in the table.

You can use a for each row/column loop statement within a response definition, action routine definition, or ESL subroutine. You can also use it within a conditional action statement or within other types of loops, to any number of levels. You can specify blocks in loops, and vice versa.

LOOP_NAME must be unique within your ESL program; there must be nothing else in the program with that name. If you specify a loop name, then you must include a matching name in the end loop statement.

Selected rows/columns may be deleted from with a table within a for each row/column loop, however, the integer variable used as a pointer must be decremented after each deletion (see in the examples below).

Example

 

# Convert and sum all cells in selected rows.

# Cells with strings that are not legal numbers are treated as 0.

 

for each selected row SelRow in MyTable loop RowSelected

    for each column CurCol in MyTable # All Columns

    loop Columns

        copy (Total + float cell column CurCol of row SelRow

            of MyTable) to Total

    end loop Columns

end loop RowSelected

 

# Clear all selected rows.

 

for each selected row SelRow in MyTable loop Rows

    clear row SelRow of MyTable

end loop Rows

 

# delete all selected rows.

 

for each selected row SelRow in MyTable loop RemoveRows

    remove row SelRow of MyTable

    copy (SelRow - 1) to SelRow

end loop RemoveRows