DICTIONARY
A dictionary defines an associative array (hash-map) of elements.
Syntax
DICTIONARY [
attributes-list ]
OF type-specification
- type-specification can be one of:
- A primitive type
- A record definition
- An array definition
- A dictionary definition
- A function type definition
- The name of a user defined type
- The name of a built-in class
- The name of an imported extension class
- The name of an imported Java class
- attributes-list is a comma-separated list of name = value pairs or name attributes, and defines attributes for the dictionary type.
Usage
A dictionary defines an associative array of unordered elements, accessed by a key.
Dictionary variables can invoke methods specific to the dictionary types.
The elements of the dictionary can be of a simple type, or structured records.
For example, to define a dictionary of
strings:
DEFINE dict DICTIONARY OF STRING
The dictionary subscript syntax consists of a character string expression (the key), specified between square brackets.
The result of the subscript syntax can be used as l-value (as target variable in assignments):
LET dict["abcdef"] = "the value"
or as r-value (in expressions):
DISPLAY dict["abcdef"]
Dictionary elements are automatically created when needed. For more details, see Dictionary in action.