Using the unpack object
unpack allows us to break lists apart into their component pieces. This can be useful in many contexts, such as performing calculations on a part of a list, accessing data from a getattr object in a physics environment, change the order of messages in a list, and much more. It can also be used to convert messages of one type into another, such as int-to-float or the other way around. Often used together with other list processing objects such as pack, route, and combine to name just a few, unpack is a key part of managing lists.
Like pack, the unpack object has as many outlets as arguments, with each outlet passing values of the same type as the corresponding argument. Lists longer than the number of outlets are truncated, while those shorter fill as many outlets as there are elements in the list with the first message in the list coming out the left outlet.
For a description of the different conversion results, refer to the help patch or reference file.
unpack is introduced together with its inverse object, pack, in Max Basic Tutorial 9: Mouse Drawing. unpack is used here to break out the x and y coordinates from the lcd object so we can use them to generate basic drawing commands, allowing us to draw rectangles and circles in addition to lines.
unpack Tips and Workarounds
Often we want to have more than one interface to work with data, but also want each interface to reflect changes made in the others. This patch uses unpack to parse out RGBA data from a swatch object so we can also use flonums to fine tune the data:
Need to unpack a list without converting anything? Try using unjoin
Third-Party Max externals similar to the unpack object
People who looked at/used this object also looked at....
Errors or Clarifications
(please list things that you believe to be errors or omissions from the existing refpage)