Please enable JavaScript to view this site.

ESL Documentation

Action Statement

Specify action statements to be performed on a member of an object class.

for each member of CLASS_NAME loop [LOOP_NAME]

[ACTION_STATEMENT] ...

[leave loop [LOOP_NAME] ]

[ACTION_STATEMENT] ...

end loop [LOOP_NAME]

CLASS_NAME

The identifier for a previously defined object class.

LOOP_NAME

The identifier for a loop. This name might identify the loop in which the leave loop is specified, or it might identify an outer loop. If you specify an outer loop, ESL leaves the specified outer loop and all inner loops. If you do not specify a name in the leave loop statement, ESL exits from the innermost loop that contains the leave loop statement, even if the innermost loop has a name.

Upon execution, exit from the loop and continue execution at the statement following the end loop keywords. The leave loop action statement can be one of the action statements in a for each member loop statement. If you specify a leave loop statement, you must specify it within the definition of the loop itself. You cannot specify it in an action routine that is called from inside the loop.

ACTION_STATEMENT

An action statement.

Description

Use the for each member loop statement to loop through the members of a class. Use the built-in function member to access the name of the current class element. You can access class members individually, as well as by group.

You can specify a for each member 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 loops, to any number of levels. You can specify blocks in loops, and vice versa. If you specify a block within a loop, execution of a leave loop statement causes all blocks contained in the loop to become inactive.

Nesting of for each member loop statements is not allowed.

Note that you cannot delete a member from a class that is currently involved in a for each member loop.

When you add members to a class, ESL adds them to the beginning of the class. Therefore, the order that objects will come out of a class is the reverse of the order in which they were added; the last object added to a class will be the first member in the for each member loop.

If a for each member loop finishes normally, then the value of member is the empty string, which is also its initial value.

If you use a leave loop statement in the middle of a for each member loop, then the last assigned value to member will continue to be the value of member.

The identifier used to name the loop must be unique within the ESL program; there must be nothing else in the program with that name. Specifying a name in the for each member loop statement means that you must include a name in the end loop statement that exactly matches the name specified in the for each member loop.

If the program is compiled with External Strings, then any string literals used in this statement will be externalized.

Example

 

# In the following example, the value of member the first

# time through is the last member added to the class CLASS.

 

for each member of CLASS loop

 send member "\n" to errorlog

end loop

 

# The following is an example of how you might associate

# values in fields from a mainframe screen with entry

# fields by assigning the host field number to the entry

# field's parameter, and then calling this loop:

 

class AllEntryFields is EF1 EF2 EF3 ...

 

# Assume each entry field is defined with host field

# number in parameter - see 3270 Support

 

for each member of AllEntryFields loop

 copy parameter of member to FieldNumber

 copy text      of member to FieldText

 call EcsWriteField (FieldNumber, FieldText, ECS_FILLWITHBLANKS)

end loop

See Also

member Special Inquiry Built-in Function