getdictionarykey
DICTIONARY
,
VALUE
,
KEY

The getdictionarykey statement returns the key of an item in the dictionary, given its value. This is essentially the opposite of the getdictionaryvalue( function (see Data Dictionaries).


Parameters

This statement has three parameters:

dictionary – name of the field or variable that contains the dictionary (must contain binary data).

value – is the value associated with the key you want to retrieve. If there are multiple objects with this value, it is indeterminate which key will be returned.

key – field or variable designated to receive the key.


Description

The getdictionarykey statement takes a value and returns the corresponding key name from the dictionary collection. If there are multiple objects with this value, it is indeterminate which key will be returned. There is also a function that can perform this same operation within a formula: see getdictionarykey(.

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 getdictionarykey statement to retrieve different keys from the dictionary, based on the values:

getdictionarykey mailto,"3987 Olive",item ☞ Address
getdictionarykey mailto,"Tustin",item ☞ City
getdictionarykey mailto,"CA",item ☞ State
getdictionarykey mailto,"92841",item ☞ Zip

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 getdictionarykey statement to retrieve different values from the dictionary:

getdictionarykey InventoryItem,10445,item ☞ SKU
getdictionarykey InventoryItem,"Widget",item ☞ Description
getdictionarykey InventoryItem,12.95,item ☞ Price

As these example show, the data type you supply must match the type of data originally stored in the dictionary. If the value was stored as a number, it must be supplied to the getdictionarykey statement as a number. For example, in this case the Price is stored as a number. If you search for it as a text value, there will be no match.

 getdictionarykey InventoryItem,"12.95",item ☞ 

If the getdictionarykey statement doesn’t find a matching value, the empty string ("") is returned. If there are multiple values that match, one of the keys will be returned. However, there is no way to know which key will be returned.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but uses new internal dictionary format