COLLECTION.INITIALIZE Function
Syntax
Arguments
- tagged_in
Describes the structure of the data in the input Data_String.
- tagged_key_out
Describes how to extract the key value from the data in the input Data_String.
- tagged_value_out
Describes how to extract the data value from the data in the input Data_String.
- string
A CR-LF delimited string.
Description
Populate a collection from a string.
Discussion
The <COLLECTION>.INITIALIZE() method populates a collection from a CR-LF delimited string. The Record_Format string describes the structure of the data in the input Data_String. The Key_Format string describes how to extract the key value from the data in the input Data_String. The Data_Format string describes how to extract the data value from the data in the input Data_String. The syntax used by the Record_Format, Key_Format, and Data_Format strings is the same as the TAGGED_PATTERN() function. See the description of this function for details. This method is extremely useful for quickly populating a collection from a string. Contrast this method with the <COLLECTION>.FROM_TABLE() method which populates a collection from a table.
Create a CR-LF delimited string.
String = <<%a% 1;Red 2;Green 3;Blue 4;Yellow %a% dim colors as u colors.initialize("1;2","1","2",string) ? colors.get("3") = "Blue"
In the above example, the number is the key and the color name is the data. Now, make the color the key and the number the data:
colors.initialize("1;2","2","1",string) ? colors.get("Red")
See Also