Package Max

coll.codebox

Store and edit a collection of data

Description

Allows for the storage, organization, editing, and retrieval of different messages, using a UI object for display and editing.

Arguments

None.

Attributes

bgcolor[4 floats]

Sets the color for the object's background frame.

editlocked[int]: 0

Allow editing of the codebox text while the patcher is locked.

embed[int]

Toggles the ability to embed the contents of the text editor with the patcher. Disable to allow for display of changing text contents that will not dirty the patcher, and prompting to save.

linenumbers[int]: 1

Show lefthand column containing line numbers for non empty lines.

linenumberwidth[int32]: 20

Set the width of lefthand line number column in pixels.

margin[int32]: 4

Set the width of the left and righthand margin in pixels

style[symbol]:

Style

textcolor[4 floats]

The default textcolor (typically overridden by syntax coloring)

precision[int]

The number of decimal places for converted floating point values (default = 6).

name[symbol]

The name of the coll. Multiple objects with the same name will share the same data. You can also share data using the refer message.

Common Box Attributes

Below is a list of attributes shared by all objects. If you want to change one of these attributes for an object based on the object box, you need to place the word sendbox in front of the attribute name, or use the object's Inspector.

annotation[symbol]

Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.

background[int]: 0

Adds or removes the object from the patcher's background layer. background 1 adds the object to the background layer, background 0 removes it. Objects in the background layer are shown behind all objects in the default foreground layer.

color[4 floats]

Sets the color for the object box outline.

fontface[int]

Sets the type style used by the object. The options are:

plain
bold
italic
bold italic Possible values:

0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'

fontname[symbol]

Sets the object's font.

fontsize[float]

Sets the object's font size (in points). Possible values:

'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'

hidden[int]: 0

Toggles whether an object is hidden when the patcher is locked.

hint[symbol]

Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.

ignoreclick[int]: 0

Toggles whether an object ignores mouse clicks in a locked patcher.

jspainterfile[symbol]

You can override the default appearance of a user interface object by assigning a JavaScript file with code for painting the object. The file must be in the search path.

patching_rect[4 floats]: 0. 0. 100. 0.

Sets the position and size of the object in the patcher window.

position[2 floats]
write-only

Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.

presentation[int]: 0

Sets whether an object belongs to the patcher's presentation.

presentation_rect[4 floats]: 0. 0. 0. 0.

Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.

rect[4 floats]
write-only

Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).

size[2 floats]
write-only

Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.

textcolor[4 floats]

Sets the color for the object's text in RGBA format.

textjustification[int]

Sets the justification for the object's text. Possible values:

0 = 'left'
1 = 'center'
2 = 'right'

varname[symbol]

Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.

Messages

int

The number refers to the address of a message stored in coll. If a message is stored at that address, the stored message is output. If the stored message is a single symbol, it is always prepended with the word "symbol" when output.

Arguments:
  • index [int]

float

The number refers to the address of a message stored in coll. If a message is stored at that address, the stored message is output. If the stored message is a single symbol, it is always prepended with the word "symbol" when output.

Arguments:
  • index [float]

list

The first value is used as the address (the storage location within coll) at which to store the remaining items in the list. The address will always be stored as an int.

Arguments:
  • index [int]
  • data [list]

(mouse)

Double-click on the coll object to display the contents as text in an editing window. The data can be manually edited within this editor.

Arguments:
  • double-click []

anything

See the symbol listing.

Arguments:
  • index [any]

append

The append message creates a new item associated with an index that is one larger than the highest current index. For example, if the coll is empty, append xyz will add an item xyz associated with the index 0. append xyz a second time will add another item xyz associated with the index 1.

Arguments:
  • data [list]

assoc

Associates a symbol with the numeric address, provided that the number address already exists. After association, any reference to that symbol will be interpreted as a reference to the number address. Each number address can have only one symbol associated with it.

Arguments:
  • address name [symbol]
  • data index [int]

bang

See the next listing.

symbol

Retrieves a message stored at the address named by the symbol. If no address is associated with the symbol, no output is produced. If the stored message is a single symbol, it is always prepended with the word "symbol" when output.

Arguments:
  • index [symbol]

clear

Clear all data

deassoc

Removes the association between a symbol and the number address. The symbol will no longer have any meaning to coll.

Arguments:
  • address name [symbol]
  • data index [int]

delete

Removes the data at the address provided. If the specified address is numeric, all higher numbered addresses are decremented by 1.

Arguments:
  • index [any]

dump

Sends all of the stored addresses out the 2nd outlet and all of the stored messages out the 1st outlet, in the order in which they are stored. A bang is sent out the 4th outlet when the dump is completed.

end

Sets the pointer (as used by the goto , next , and prev messages) to the last address.

filetype

Sets the file types which can be read and written into the coll object. The message filetype with no arguments restores the default file behavior.

Arguments:
  • filetype [symbol]

flags

Sets the flags used to save its contents within the patch that contains it. The message flags 1 0 notifies the object to save its contents as part of the patcher file. The message flags 0 0 causes the contents not to be saved.

Arguments:
  • save-setting [int]
  • unused [int]

goto

Sets the pointer (as used by the goto , next , and prev messages) at a specific address, but does not trigger output. If the specified address does not exist, the pointer is set at the beginning of the collection. Data will be output in response to a subsequent bang , next , or prev message.

Arguments:
  • index [list]

insert

Inserts the message at the address specified by the number, incrementing all equal or greater addresses by 1 if necessary.

Arguments:
  • index [int]
  • data [list]

insert2

See the insert listing.

Arguments:
  • index [int]
  • data [list]

length

Counts the number of entries contained in the coll and sends the number out the 1st outlet.

max

Gets the highest value in any entry. An optional integer argument (defaults to '1') specifies an element position to use.

Arguments:
  • element [int]

merge

Appends data at the end of the data found at the specified index. If the address does not yet exist, it is created.

Arguments:
  • index [int]
  • data [list]

min

Gets the lowest value in any entry. An optional integer argument (defaults to '1') specifies an element position to use.

Arguments:
  • element [int]

next

Sends the address and data stored at the current address, then sets the pointer to the next address. If the pointer is currently at the last address in the collection, it wraps around to the first address. If the address is a symbol rather than a number, 0 is sent out the second outlet.

nstore

Stores the message at the specified number address, with the specified symbol associated. This has the same effect as storing the message at an int address, then using the assoc message to associate a symbol with that number.

Arguments:
  • index [int]
  • association [symbol]
  • data [list]

nsub

Replaces a data element with a new value. As an example, nsub 2 4 7 replaces the fourth element of address 2 with the value 7. Number values and symbols can both be substituted in this manner.

Arguments:
  • index [int]
  • position [int]
  • data [any]

nth

Returns the data element found at a specific position in the stored list and send it out the first outlet. As an example, nth 75 2 will output the second item in the list stored at address 75.

Arguments:
  • index [int]
  • position [int]

open

Opens a data editing window for the current data and bring it into focus.

prev

Sends the address and data stored at the current address, then sets the pointer to the previous address. If the pointer is currently at the first address in the collection, it wraps around to the last address. If the address is a symbol rather than a number, 0 is sent out the second outlet.

read

With no arguments, read puts up a standard Open Document dialog box to choose a file to load. If an argument is provided, the named file is loaded.

Arguments:
  • filename [symbol]

readagain

Loads the contents of the most recently read file. If no prior file load has occurred, the request is treated like a read message.

refer

Changes the reference to the data in another named coll object. Changes to the data stored in any referenced coll will be shared by all other objects with the same name.

Arguments:
  • object name [symbol]

remove

Removes that address and its contents from the collection.

Arguments:
  • index [any]

renumber

Renumbers data entries as consecutive and in increasing order. The optional argument specifies the starting number address for the data.

Arguments:
  • data index [int]

renumber2

Increment indices by one

Arguments:
  • data index [int]

separate

Increments the numerical indices for all data whose index is greater than the provided. This creates an open 'slot' for a subsequent add.

Arguments:
  • data index [int]

sort

Sorts the data into a specified order. If the first argument is -1 , the items are sorted in ascending order. If the first argument is 1 , the items are sorted in descending order.
The second argument specifies what data is used to sort the contents. If the second argument is -1 , the index (either number or symbol) associated with the data is used. If the second argument is not present or is 0 , the first item in the data is used. If the second argument is 1 or greater, that data elements is used for the sorting order.

Arguments:
  • sort order (-1 or 1) [int]
  • entry (-1, 0, or 1) [int]

start

Sets the pointer (used by the goto , next , and prev messages) to the first address in the coll.

store

Stores the message at an address named by the provided symbol. As an example, store triad 0 4 7 will store 0 4 7 at an address named triad .

Arguments:
  • index [symbol]
  • data [list]

sub

Same as nsub , except that the message stored at the specified address is sent out after the item has been substituted.

Arguments:
  • index [int]
  • position [int]
  • data [list]

subsym

Changes the symbol associated with data. The first argument is the new symbol to use, the second argument is the symbol associator to replace.

Arguments:
  • new name [symbol]
  • old name [symbol]

swap

Exchanges the indices associated with two addresses. The data is unchanged, but the indexes that they use are swapped.

Arguments:
  • index [int]
  • index [int]

wclose

Close the data editing window

write

With no arguments, write puts up a standard Open Document dialog box to choose a filename to write. If an argument is provided, the name is used as a filename for storage.

Arguments:
  • filename [symbol]

writeagain

Saves the contents to the most recently written file. If no prior file write has occurred, the request is treated like a write message.

See Also

Name Description
coll Store and edit a collection of data
dict Create and access dictionaries
dict.codebox Create and access dictionaries