combining complex messages, best practices?

ivan dauhalevich's icon

Hello! I have an idea to ensure the interaction of modules through complex messages that looks something as (prefix1 value1, prefix2 value2, prefix3 value3), where prefix is a label you attach to values (as if you were using prepend object for the value) to operate on them through route for example, and value is some data type which could be of any data type including list. I understand how to parse the messages, but i have issues with constructing them, i tried using zl.group, zl.lace etc. which, according to my assumptions, should have brought enough clarity to the solution of my problem, but in reality it led to an unpredictable final result. So what should i do to derive a homogeneous way of constructing such messages? I haven't managed to find any decent material on that topic, so can you suggest me some?

how.maxpat
Max Patch

TFL's icon

is equivalent to

as messages will be sent in the same order at the same speed.

So no need to compose messages with commas, just separate messages is enough and easier to work with. You can compose them with [pack], [pak], [join], [prepend], messages with $1 signs, etc. among countless other solutions.

Using dicts is another approach, although maybe not the most obvious nor practical here:

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

If you really really want to make your messages with commas, or make use of your [zl.lace], there are solutions too, but most likely not the best ones. Without a bigger picture of what you really want to achieve (how are set these values? What are their destination(s)? how frequently do they change?), it's hard to help you further.

Source Audio's icon

1- where should all this values come from and how do you link them to specific index ?

like what makes Step 1 different from Step 2 ?

2- where do you want to store / recall that messages ?

collecting few items into list is a trivial task,

no matter if list should be comma separated or not

but commas in max will give you problems because in max

comma in a message works like iter.