ArrayDictionary

An arrayDictionary part is a part that is always available; you do not define it. A variable that is based on an arrayDictionary part lets you access a series of arrays by retrieving the same-numbered element of every array. A set of elements that is retrieved in this way is itself a dictionary, with each of the original array names treated as a key that is paired with the value contained in the array element.

An arrayDictionary is especially useful in relation to the display technology described in Console user interface.

The next graphic illustrates an arrayDictionary whose declaration includes arrays that are named ID, lastname, firstname, and age. The ellipse encloses a dictionary that includes the following key-and-value entries:
  ID = 5,
  lastName = "Twain",
  firstName = "Mark",
  age = 30

Illustration of an array dictionary

The array of interest is the array of dictionaries, with each dictionary illustrated as being one above the next rather than one alongside the next. The declaration of the arrayDictionary requires an initial list of arrays, however, and those are illustrated as being one alongside the next.

The following code shows the declaration of a list of arrays, followed by the declaration of an arrayDictionary that uses those arrays:
  ID        INT[4];
  lastName  STRING[4];
  firstName STRING[4];
  age       INT[4];

  myRows ArrayDictionary
  {
    col1 = ID,
    col2 = lastName,
    col3 = firstName,
    col4 = age
  }; 

To retrieve values, your code uses a syntax that isolates a particular dictionary and then a particular field (a key-and-value entry) in that dictionary. You cannot use the arrayDictionary syntax to update a value or to change any characteristic of the arrayDictionary itself.

First, declare a dictionary and assign an arrayDictionary row to that dictionary, as in this example:
  row Dictionary = myRows[2];
Next, declare a variable of the appropriate type and assign an element to that variable, as in either of these examples:
  cell INT = row["ID"];

  cell INT = row.ID;
An alternative syntax retrieves the value in one step, as in either of these examples:
  cell int = myRows[2]["ID"];

  cell int = myRows[2].ID; 

Related concepts
Console user interface
Dictionary
References to variables in EGL

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.