Example 2 Collections do not Need to Be Keyed by Index

Visual LANSA

Example 2: Collections do not Need to Be Keyed by Index

Unlike an array, a keyed collection does not have to be keyed by an index. This example is otherwise the same as Example 1 except that the collection of employees is keyed by the #Surname field instead of a number.

When you type in an employee name and click on the Save button, the employee name is saved in a collection.

When you click on the Show button, all employees entered in the collection are displayed in a message box.

The collection is uniquely keyed by #SurName so a duplicate name will update the existing item in the collection.

Define the Collection

Add Items to the Collection

Work with the Collection Items

Source Code for Collection Example 2

Ý 6.22.3 Keyed Collections