A newer version of Max is available. Click here to access the latest version of the documentation

dict Reference

Create and access dictionaries

dict

Description

Use the dict object to create named dictionaries, clone existing dictionaries, and query existing dictionaries to access their data.

Arguments

name [symbol]

Optional

Name to be associated with this dictionary. If no argument is given, then a unique name will be generated.

filename [symbol]

Optional

Name of a JSON or YAML file to be imported into this dictionary on load.

Attributes

embed [int]

Toggles the ability to embed the contents of the dict as part of the main paitch. If the embed attribute is set to 1, this overrides this attribute on any other dicts with the same name.

name [symbol]

Name associated with the dictionary. All dictionaries are passed by reference using a symbolic name. If you do not provide a name, a unique name will be generated internally.

parameter_enable [int]

Enables use of this object with Max for Live Parameters.

parameter_mappable [int] (default: 1)

When parameter_mappable is enabled, the object will be available for mapping to keyboard or MIDI input using the Mappings feature.

quiet [int]7.0.0

Reduce error checking and reporting when operations are performed on the dict. When an error occurs the result will typically be a silent failure when this option is turned-on.

Common Box Attributes

Parameter Attributes

Messages

bang

Send a reference to the dictionary from the first outlet.

append

Arguments

key [symbol]
value [list]
Add values to the end of an array associated with the specified key.

clear

Erase the contents of the dictionary, restoring to a clean state.

clone

Arguments

name [symbol]
Make a clone of the incoming dictionary. If received at the first inlet, send a reference to this new clone from the first outlet. Otherwise just clone the dictionary and don't send it out.

contains

Arguments

key [symbol]
Return a 0 or 1 to the third outlet indicating the specified key exists (or doesn't) in the dictionary.

(mouse)

Double-click a dict object to open a dictionary editor window.

dictionary

Arguments

name [symbol]
Make a clone of the incoming dictionary. If received at the first inlet, send a reference to this new clone from the first outlet. Otherwise just clone the dictionary and don't send it out.

edit

Open the dictionary editor window.

export

Arguments

filename [symbol]
Write the dictionary contents to a JSON or YAML file. If no path/filename is provided, a dialog will be presented. The file format is determined from the file name extension, either '.json' or '.yaml'.

get

Arguments

key [symbol]
Return the value associated with a key to the second outlet.

getkeys

Arguments

alphabetize [bool]
Return a list of all the keys in a dictionary to the third outlet. By default the keys are sorted according to the order in which keys were added to the dictionary. Use the optional argument to specify alphabetical sorting.

getnames

Return a list of all the dictionaries that currently exist to the fourth outlet.

getsize

Arguments

key [symbol]
Return the number of values associated with a key to the second outlet.

gettype7.0.0

Arguments

key [symbol]
Return the type of the values associated with a key to the second outlet.

import

Arguments

filename [symbol]
Read the dictionary contents from a JSON or YAML file. If no path/filename is provided, a dialog will be presented. The file format is determined from the file name extension, either '.json' or '.yaml'.

parse7.0.0

Arguments

key [symbol]
value [symbol]
Replace the content of a dictionary by providing the new content as JSON.

pull_from_coll

Arguments

coll-name [symbol]
Pull the content of a named coll object into the dictionary. The indices in the coll will become the keys, and the values for those indices the values for the dictionary's keys.

push_to_coll

Arguments

coll-name [symbol]
Push the dictionary's content into a named coll object. The keys in the dictionary will become the indices in the coll, and the values for those indices the values of the dictionary's keys.

read

Arguments

filename [symbol]
Read the dictionary contents from a JSON or YAML file. If no path/filename is provided, a dialog will be presented. The file format is determined from the file name extension, either '.json' or '.yaml'.

readagain

re-reads an JSON or XML file previously specified by the read or write messages. If no file has been previously specified, a standard File Dialog will be presented for the user to manually choose the file to be read.

readany7.0.0

Arguments

filename [symbol]
Read the dictionary contents from a JSON or YAML file. If no path/filename is provided, a dialog will be presented. The file format and extension are not checked. The contents of the file are assumed to be in JSON format.

remove

Arguments

key [symbol]
Remove a key and its associated value from the dictionary.

replace

Arguments

key [symbol]
value [list]
Set the value for a key to a specified value. If a heirarchy is specified for the key, and the heirarchy does not exist, then it will be created in the dictionary.

set

Arguments

key [symbol]
value [list]
Set the value for a key to a specified value.

setparse7.0.0

Arguments

key [symbol]
value [symbol]
Set the value for a key to dictionary content defined using JSON.

wclose7.0.0

Close the dictionary editor window if it is open.

write

Arguments

filename [symbol]
Write the dictionary contents to a JSON or YAML file. If no path/filename is provided, a dialog will be presented. The file format is determined from the file name extension, either '.json' or '.yaml'.

writeagain

Write the dictionary contents to a JSON or YAML file. The file provided as an argument for the previous 'write' or 'export' message will be used.

See Also

Name Description
JavaScript Usage JavaScript Usage
dict.view
dict.pack
dict.unpack
dict.group
dict.iter
dict.join
dict.slice
dict.print
dict.route
dict.strip
dict.serialize
dict.deserialize
Dictionaries Dictionaries
External Text Editor External Text Editor