A Dictionary part is always available; you do not define it. A variable that is based on a Dictionary part includes a set of keys and their related values. You can add and remove key/value entries at run time. Use the key names in a program just as you would field names in a record. The dictionary variable keeps the entries in the order that you entered them.
myRef Dictionary { ID = 5, lastName = "Twain", firstName = "Mark" };
When you include entries in the declaration, each key name is an EGL identifier that must be consistent with EGL naming conventions. When you add entries at run time, you have greater flexibility; see "Dynamic types and dynamic access."
myRef.age = 30; myRef["Credit"] = 700;
myRef.lastname = "Clemens";
lastname STRING age, credit INT; lastname = myRef.lastname; age = myRef["age"]; credit = myRef.credit;
Record ExampleRecord x int; end
The next example places an ExampleRecord variable into the dictionary, then changes the value of the original variable:
testValue int; myRecord ExampleRecord; // sets a variable value and places // a copy of the variable into the dictionary. myRecord.x = 4; myRef Dictionary { theRecord = myRecord }; // Places a new value in the original record. myRecord.x = 700; // Accesses the dictionary's copy of the record, // assigning 4 to testValue. testValue = myRef.theRecord.x;
myRef Dictionary { age = 30 }; newRef Dictionary { age = 50 }; newRef = myRef; // resolves to true if (newRef.age == 30) ; end
Properties that you can specify in the declaration affect how the dictionary is processed; see "Dictionary properties." Dictionary-specific functions provide data and services to your code; see "Dictionary functions."
Platform | Issue |
---|---|
COBOL generation | The Dictionary part is not currently available in code generated for COBOL. |