copypartialdictionary(
DICTIONARY
,
KEY
)

The copypartialdictionary( function partially copies a dictionary (see Data Dictionaries).


Parameters

This function has two parameters:

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

key – is the name of the key to copy. If you need to copy more than one key/value pair, more than one key parameter can be used.


Description

The copypartialdictionary( function takes one or more key names and copies the associated key/value pairs from the original dictionary into a new one. For example, suppose you created a dictionary and stored it in variable named contact.

fileglobal contact,mailto
contact=initializedictionary("First","John","Last","Wilson",
    "Address","3987 Olive","City","Tustin","State","CA","Zip","92841",
    "Phone","562-309-5923","Email","jwilson@someisp.com")

Later, you could use the copypartialdictionary( function to create a second dictionary, called mailto, that contains just the address information (without the phone number, e-mail, or any other entries that may have been added to the original dictionary):

mailto=copypartialdictionary(contact,"Address","City","State","Zip")

Starting with Panorama X 10.2, the copypartialdictionary( function allows the second parameter to be a carriage return separated list of key names. When used this way, there must be only two parameters, not three or more. Here is an alternative version of the code above using this technique.

mailto=copypartialdictionary(contact,commatocr("Address,City,State,Zip"))

The advantage of this alternate method is that you can calculate the list of key names “on-the-fly.” This example creates a new dictionary with only items in the original dictionary that have names that begin with Shipping, for example ShippingAddress, ShippingCity, ShippingPhone, etc.

shipinfo=copypartialdictionary(contact,
    arraystrip(arrayfilter(listdictionarykeys(contact),cr(),
        {?(import() beginswith "Shipping",import(),"")}),cr())

See Also


History

VersionStatusNotes
10.2UpdatedIf there are only two parameters, the second parameter is now a carriage return delimited list of keys to copy, making it easier to generate the list of keys with a calculation.
10.0UpdatedCarried over from Panorama 6.0, but now available as a function. Also, this operation no longer corrupts the dictionary if the same key is listed more than once.