8.12.1 FOR Parameters
EACH
IN
KEY
OPERATION
EACH
The EACH parameter names a variable that will be defined for the scope of the FOR/ENDFOR block to be a reference to the current component being supplied by the iterator.
By default, the type of this variable is that of the type of the component being collected by the collection from which the iterator was created. This can be changed by the OPERATION(…) parameter.
IN
The IN parameter identifies the collection to be iterated through. The collections can be user-defined or primitive LANSA collections.
User-defined collection types are:
Keyed collection
|
Keyed collection. Keyed collections are an unordered sequence of components identified by a key value. No duplicates of the key value are allowed.
Note that because there is no predefined ordering of items in a keyed collection, there is no guaranteed order in which the items will be returned when iterating through the collection.
|
List collection
|
A List collection. List collections provide an ordered collection of components. The features of the list component are positional in nature, in reference to a given index or to the beginning or end of the list. Indexing is always relative to 1.
|
Array collection
|
An array collection. Array collections are a dynamically sized, ordered collection of components that can be located by indexing. Indexing is always relative to 1.
|
Sorted array collection
|
A sorted array collection. Sorted array collections are a dynamically sized, sorted collection of components that can be located by indexing. Indexing is always relative to 1.
|
Set collection
|
A set collection. Set collections are an unordered collection of components that cannot contain duplicates.
|
Dictionary collection
|
A dictionary collection. Dictionary collections are an unordered sequence of key-value component pairs with no duplicates of the key.
|
Sorted dictionary collection
|
A sorted dictionary collection. Sorted dictionary collections are a collection of key-value component pairs. The collection is sorted by the key component and no duplicates of the key are allowed.
|
|
Primitive LANSA collections are accessed using these properties:
ComponentMembers property
|
The ComponentMembers property of a component provides access to the collection of all its member components. All components that are owners of other components have this property.
|
ComponentControls property
|
All composite visual components ( like forms, panels, tabbed folders, etc) support the ComponentControls property which enables access to its children controls.
|
Items property
|
The Items property provides access to the items in grids, list views, tree views, tree view items, list boxes, combo boxes, property sheets and menus.
For a menu the Items property provides a collection of all the menu items contained in MenuBar, Popup and SubMenu components.
|
Columns property
|
The Columns property provides access to the attributes of columns in grids, list views, tree views, list boxes, combo boxes and property sheets.
|
ComponentForms property
|
The ComponentForms property of component #SYS_APPLN provides a collection of all the forms currently realized by the application.
|
|
KEY
Some collections provide a key.
Keyed collections have a key which is the type of the field defined in the KeyedBy parameter. Other collections have keys that are simply indexes.
If you want access the current key of the current component, you specify a name for the KEY parameter and Visual LANSA will automatically provide access to the current key each time you reference the variable name in the FOR/ENDFOR block.
OPERATION
This parameter lets you do casting operations in order to select specific kinds of objects from the collection.
*DEFAULT
|
All items are selected.
|
*INSTANCE_OF ClassName
|
Checks if the variable is of the type identified by the class name or of the type of ancestors identified by the class name.
|
*KIND_OF ClassName
|
Checks if the variable is of the class identified by the class name value.
|
*DYNAMIC #VariableName
|
Assigns the reference contained in the variable name to each of the variables identified by the EACH parameter. No compile time checking is performed to see if the variables are compatible.
At run-time, if the variable name cannot be cast to any of the variables identified by the EACH parameter, an error is raised.
|
|