getdictionarykey
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

- appenddictionaryvalue -- appends a value to an item in a dictionary (see Data Dictionaries).
- changedictionaryname -- changes the name (key) of an item in a dictionary (see Data Dictionaries).
- changedictionaryvalues( -- changes one or more values in a dictionary (see Data Dictionaries).
- clearglobaldictionaryvalues -- clears (removes) all the keys and values from the specified global dictionary.
- copypartialdictionary -- builds a new dictionary and initializes it with values from an existing dictionary (see Data Dictionaries).
- copypartialdictionary( -- partially copies a dictionary (see Data Dictionaries).
- Data Dictionaries -- Overview of Panorama's key/value data dictionaries.
- deletedictionaryvalue -- deletes a key/value pair from a dictionary (see Data Dictionaries).
- deletedictionaryvalue( -- deletes one or more key/value pairs from a dictionary (see Data Dictionaries).
- deleteglobaldictionaryvalues -- deletes one or more global dictionary values.
- dictionaryassignmentscode( -- returns code that can be used to take the values in a dictionary (see Data Dictionaries) and assign them to fields or variables based on the dictionary keys.
- dictionarydifference -- builds an array that lists keys of dictionary values that are different between two dictionaries (see Data Dictionaries).
- dictionaryfromarray( -- builds a new dictionary and initializes it from a two dimensional text array (see Data Dictionaries and Text Arrays).
- dictionaryfromvariables( -- builds a new dictionary and initializes it from a list of variables (carriage return delimited).
- dictionaryvalueexists -- returns true or false depending on whether or not a key/value pair exists in a dictionary (see Data Dictionaries).
- dictionaryvalueexists( -- returns true or false depending on whether or not a key/value pair exists in a dictionary (see Data Dictionaries).
- dumpdictionary -- returns a carriage return separated array of dictionary keys and values (see Data Dictionaries).
- dumpdictionary( -- returns a carriage return separated array of dictionary keys and values (see Data Dictionaries).
- dumpdictionaryquoted -- returns a carriage return separated array of dictionary keys and values (see Data Dictionaries).
- dumpdictionaryquoted( -- returns a carriage return separated array of dictionary keys and values (see Data Dictionaries). The text values are quoted.
- dumpdictionarysource( -- returns a carriage return separated array of dictionary keys and values (see Data Dictionaries). The keys and values are quoted so that they could be used to re-assemble the dictionary with the initializedictionary( function.
- getdictionarykey( -- returns the key of an item in the dictionary, given its value). This is essentially the opposite of the getdictionaryvalue( function (see Data Dictionaries).
- getdictionaryvalue -- returns the value of an item in the dictionary, given its key (see Data Dictionaries).
- getdictionaryvalue( -- returns the value of an item in the dictionary, given its key (see Data Dictionaries).
- getglobaldictionary( -- converts a global dictionary into a regular dictionary.
- Global Dictionaries -- alertnate high performance method to store multiple data items, much faster than regular data dictionaries.
- globaldictionarybuild -- builds a global dictionary by scanning a database.
- globaldictionarykeys( -- returns a cr()-separated array containing the keys in a global dictionary, or the names of all global dictionaries.
- globaldictionaryvalue( -- returns the value of an item in a global dictionary, given its key (see Global Dictionaries).
- info("timerinfo") -- returns a dictionary that contains all of the properties of the currently running timer.
- initializedictionary -- builds a new dictionary and initializes it with one or more key/value entries (see Data Dictionaries).
- initializedictionary( -- builds a new dictionary and initializes it with one or more key/value entries (see Data Dictionaries).
- initializedictionaryvalue( -- builds a new dictionary and initializes it with one or more entries (see Data Dictionaries). This function is deprecated, we recommend using the initializedictionary( function instead.
- listdictionarykeys( -- returns a list of the keys in a dictionary collection.
- listdictionarynames -- returns a list of the names (keys) in a dictionary (see Data Dictionaries).
- mergedictionaries -- merges the contents of two or more dictionaries (see Data Dictionaries).
- mergedictionaries( -- merges the contents of two or more dictionaries (see Data Dictionaries).
- renamedictionarykey( -- changes the key (name) of one or more values in a dictionary (see Data Dictionaries).
- setdictionaryvalue -- changes a value in a dictionary (see Data Dictionaries).
- setglobaldictionaryvalues -- sets one or more key/value pairs in a global dictionary.
- setlocalsfromdictionary -- converts a dictionary into a collection of local variables. The names and values of the local variables will be derived from the dictionary contents.
- timerinfo( -- returns a dictionary that contains all of the properties of a timer.

History

Version | Status | Notes
10.0 | Updated | Carried over from Panorama 6.0, but uses new internal dictionary format