The getdictionaryvalue statement returns the value of an item in the dictionary, given its key (see Data Dictionaries).
This statement has four parameters:
dictionary – name of the field or variable that contains the dictionary (must contain binary data).
key – is the name of the key for the value you want to retrieve.
value – field or variable designated to receive the value.
default – value to be used if the specified key does not exist in the dictionary. This may be any type of value, including an error (generated with the error( function. If this parameter is omitted, the default value will be empty text (
The getdictionaryvalue statement takes a key name and returns the corresponding value from a dictionary collection. There is also a function that can perform this same operation within a formula: see getdictionaryvalue(.
Suppose you created a dictionary and stored it in variable named mailto.
fileglobal mailto,item mailto=initializedictionary("Address","3987 Olive","City","Tustin","State","CA","Zip","92841")
Later, you could use the getdictionaryvalue statement to retrieve different values from the dictionary:
getdictionaryvalue mailto,"Address",item ☞ 3987 Olive getdictionaryvalue mailto,"City",item ☞ Tustin getdictionaryvalue mailto,"State",item ☞ CA getdictionaryvalue mailto,"Zip",item ☞ 92841
Dictionary values are not restricted to text – you can use any type of data that Panorama supports, including numbers, dates, and binary data. This example includes both numbers and a date.
fileglobal InventoryItem,item InventoryItem=initializedictionary("SKU",10445,"Description","Widget","Price",12.95, "On Hand",687,"Last Order Date",date("12/17/2012"))
Later, you could use the getdictionaryvalue( function to retrieve different values from the dictionary:
getdictionaryvalue InventoryItem,"SKU",item ☞ 10445 (integer number) getdictionaryvalue InventoryItem,"Description",item ☞ Widget (text) getdictionaryvalue InventoryItem,"Price",item ☞ 12.95 (floating point number)
The examples above all assume the requested dictionary item actually exists. If it doesn’t, the statement will return empty text (
""). You can add a fourth parameter to specify a different default value, for example perhaps 0 for numeric dictionary items, or an error.
Advanced Note: If you used dictionaries in a previous version of Panorama (6.0 or earlier), the internal format used for dictionary collections has changed. The older version supported only MacOSRoman encoded text (no Unicode text), and did not support non text values. The new format lifts both of these restrictions. The old format is still supported in “read-only” mode for compatibility with existing databases. The data in an old format dictionary can still be accessed, but will automatically be converted to the new format if any changes are made.
|10.0||Updated||Carried over from Panorama 6.0, but uses new internal dictionary format. Also now has optional default parameter.|