Working Around 9 Variable Limit in Message Box

Morgan's icon

Greetings list,

I'm porting a patch from PD that uses message boxes with more than 9 variables, i.e. ($1 $3 $13). The message boxes are used to format OSC commands. How can I work around this?

Unfortunately I can't just split the list because some messages take variables >9 spaces apart.

Max Patch
Copy patch and select New From Clipboard in Max.

Please have a look at this patch:

Thanks!

Morgan's icon

Totally forgot about sprintf, but I'm not sure if there's a good solution there nevertheless.

Morgan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Ok, here's my disgusting hack using [zl nth], [zl join] and [sprintf]. I hope there's a better way.

Roman Thilenius's icon

if the input is of a constant lenght, and the type of the variables
is known, you could just use list/pack/pak.

stupid 100 200 300
|
"set $1 thing $2 $3 $4"
 ==
[list set x thing 0 0 0]

Morgan's icon

@Roman I'm not sure I understand.

(1 2 3 4 5 6 7 8 9 10)
|
[pak $10]

==

"$10"

Max Patch
Copy patch and select New From Clipboard in Max.

I need to access the nth element of a list and pack it into a message. See my final (ugly, but hidden) solution below using nth and join.

spectro's icon

Couldn't you just send OSC messages at the source and use osc-route at the receiver?, or am I missing something?

Roman Thilenius's icon

(1 2 3 4 5 6 7 8 9 10)
|
[unpack]
||||||||||
[pak 0 0 0 0 0 or have some symbols and a 7 here 0 0 0 0 0]

no?

Morgan's icon

@spectro I can't modify the receiver's API

@Roman Oh, I see. Indeed that would work, though it would lead to a mess of wires. At this point I have it working with my convoluted [zl] mess and its sufficiently abstracted, so I think I'll leave it that way.

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks for the suggestions. For those in the future, here's the basic idea:

cap10subtext's icon

The patch I listed uses pak and sprintf to get around the limit.