Simple question about lists and writing text files

Mar 4, 2012 at 5:16pm

Simple question about lists and writing text files

Hi all,
i have started with max today and i am wondering:
1 – How to Append Elements to a Message Box (for example i have a message button in which is written ‘a’ and i want that everytime i press this button it appends a in the new message button, so after i press 5 times this button i have in the new message box ‘a a a a a’.

2 – How to print on a text file the text of a message box.


Mar 4, 2012 at 5:40pm

For 1 take a look at : join and zl objects
For 2 : coll

Mar 5, 2012 at 8:09am

Thank you for your reply.. i tried to do what is in the attached image file but it will not prepend nothing just set a new message…
I want that everytime i click on a it will add another a so if message box is 'a' after i click another time 'a' must be 'a a'.

How possible?



  1. corrmax.JPG
Mar 5, 2012 at 12:03pm

The messageobject has 2 inlets, and they work differently (true for almost all objects) Most important: the leftmost inlet sets a value and sends it out immediatly (hot inlet in the max language, in opposite to cold inlet, in general the rightmost inlet). The messagebox is little different: when you connect the leftmost inlet, nothing ist set, if you connect left inlet message is set, but nothing sent out. Therefore the prepend instruction SET, connectet to the messagebox, will constrain the messagebox to actually set the message: in your case only that message coming in ABOVE the PREPEND object, so if you wanted to prepend again is after the message created (this is a basic but very helpfull exemple to understand what I would call the chain of instruction or instanciation: is important to understand to get what you want. The solution of your issue is more tricky: check sprintf

Mar 5, 2012 at 12:52pm

i cannot understand still… I just need message box called ‘a’ and everytime i press on it it must add another ‘a’ in a new message box.
It is the simple prepend function of LISP applied to list.
Is not possible using prepend???

Mar 5, 2012 at 9:58pm

is this what you are looking for?

– Pasted Max Patch, click to expand. –
Mar 6, 2012 at 1:06am

also, please spend more than a day doing the max tutorials before trying to implement LISP functions ;)

Mar 6, 2012 at 1:24am
Mar 6, 2012 at 8:06am

is there a command ‘prepend’ in lisp? I only know ‘cons’…?


Mar 6, 2012 at 11:44am

I made these “zl append” and “zl prepend” abstractions a while ago, and I use them quite often :

– Pasted Max Patch, click to expand. –
Mar 8, 2012 at 11:09pm

@Guillaume Bertrand

Yes your example were perfect Thank you a lot.
Also i will try to see that Max Lisp :)

Mar 9, 2012 at 6:00am
– Pasted Max Patch, click to expand. –
Mar 11, 2012 at 10:52am

thanks christopher :)

Mar 13, 2012 at 3:10pm

or use zl group. only on object ;-)

– Pasted Max Patch, click to expand. –

You must be logged in to reply to this topic.