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

pack

Combine numbers and symbols into a list

Description

pack takes separate items and combines them into an output list.

Arguments

Name Type Opt Description
initialize-inlet-formats int float symbol opt The number of inlets is determined by the number of arguments. Each argument sets an initial type and value for an item in the list stored by pack. If a number argument contains a decimal point, that item will be stored as a float. If the argument is a symbol, that item will be stored as a symbol. If there is no argument, there will be two inlets, and the two list items will be set to (int) 0 initially. Note: Typing a list into an object box automatically identifies it as a pack object, so you may omit the word pack from the object box, provided that you type in a list of arguments (that has at least two items and begins with a number).

Messages

bang In left inlet: Causes pack to send out a list of the items currently stored.
int input [int]
The number is stored in pack as an item in a list, with its position in the list corresponding to the inlet in which it was received. A number in the left inlet is stored as the first item in the list, and causes the entire list to be sent out the outlet. If the inlet in which the number is received has been initialized with a float or symbol argument, the incoming number will be converted to a float or a blank symbol, respectively.
float input [float]
The number is stored in pack as an item in a list, with its position in the list corresponding to the inlet in which it was received. A number in the left inlet is stored as the first item in the list, and causes the entire list to be sent out the outlet. If the inlet in which the number is received has been initialized with an int or symbol argument, the incoming number will be converted to an int or a (blank) symbol, respectively. If no argument has been typed in, float is converted to int.
list input [list]
Any multi-item message, regardless of whether it begins with a number, is treated as a list by pack. The first item in the incoming list is stored in pack in the location that corresponds to the inlet in which it was received, and each subsequent item is stored as if it had arrived in subsequent inlets (limited by the number of inlets available). A list received in the left inlet causes the entire stored list to be sent out the outlet.
anything input [list]
Performs the same function as list.
nth inlet-number [int]
The word nth, followed by the number of an inlet (starting at 1 for the leftmost inlet), causes the value of the item stored at that location in pack to be sent out the outlet.
send receive-object-name [list]
In left inlet: The word send, followed by the name of a receive object, sends a list of the currently stored items to all receive objects with that name, instead of out pack object's outlet.
set set-input [list]
The word set, followed by any message, allows that message to be received by pack without triggering any output. Although a set message may be received in any inlet, it is only meaningful in the left inlet, which is the only triggering inlet. In any other inlet, the word set is ignored and the rest of the message is used as normal.
symbol input [symbol]
If the inlet in which the symbol is received has been initialized with a symbol argument, the symbol is stored in the corresponding location in pack. Otherwise, the symbol is converted to 0 before being stored. A symbol in the left inlet triggers output of the pack object's contents.

Information for box attributes common to all objects

Output

int float symbol: When the nth message is received, the value of the specified item is sent out.
list: The length of the list is determined by the number of arguments. When input is received in the left inlet, the stored list is sent out the outlet.

Examples

Numbers and symbols may be mixed as needed in pack

See Also

Name Description
bondo Synchronize a group of messages
buddy Synchronize arriving data, output them together
match Look for a series of arguments, output it as a list whenever an input matches
swap Reverse the sequential order of two integers
thresh Combine numbers into a list when received close together
unpack Break a list into individual messages
zl Multi-purpose list processing
Max Basic Tutorial 9: Mouse Drawing Max Basic Tutorial 9: Mouse Drawing