The Dict object in JS is a companion to the dict object you create in a Max patcher. It provides the ability to access structured data (a dictionary) associated with a name.
Dict Constructor
var d = new Dict("name")
If no name is provided as an argument then a unique name will be generated for the dictionary.
The following properties mirror the attributes of the same name from the Max dict object. See the dict reference for more details.Dict Properties
name [symbol]
Access or set the name of a dict object as a property of the dict object
quiet [boolean] (default: false)
The quiet property functions the same as the @quiet attribute to dict in Max. It suppresses many errors or warnings if set to true.
Dict Methods
append
Arguments
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
Make a clone of the incoming dictionary.
contains
Arguments
Return a 0 or 1 indicating the specified key exists (or doesn't) in the dictionary.
get
Arguments
Return the value associated with a key.
getkeys
Return a list of all the keys in a dictionary.
getnames
Return a list of all the dictionaries that currently exist.
getsize
Return the number of values associated with a key.
gettype
Return the type of the values associated with a key.
parse
Arguments
value [symbol]
Replace the content of a dictionary.
pull_from_coll
Arguments
Pull the content of a named coll object into the dictionary.
push_to_coll
Arguments
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.
readany
Arguments
Read the dictionary contents from a file.
remove
Arguments
Remove a key and its associated value from the dictionary.
replace
Arguments
value [list]
Set the value for a key to a specified value, creating heirarchy.
set
Arguments
value [list]
Set the value for a key to a specified value.
setparse
Arguments
value [list]
Set the value for a key to dictionary content defined using JSON.
writeagain
Open a save dialog to write the dictionary contents to a file.
stringify
Return the content of the dictionary as a JSON string.
import_json
Arguments
Read a file from disk in the JSON format.
export_json
Arguments
Write a file to disk in the JSON format.
import_yaml
Arguments
Read a file from disk in the YAML format.
export_yaml
Arguments
Write a file to disk in the YAML format.
Examples
Example code can be found in the "js" tab of the dict help patcher.See Also
Name | Description |
---|---|
JavaScript Usage | JavaScript Usage |