Simple question about lists and writing text files

nickv91's icon

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.

Thanks

Spip's icon

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

nickv91's icon

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?

thanks

3480.corrmax.JPG
JPG
Helmuth's icon

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

nickv91's icon

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???

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

is this what you are looking for?

Wetterberg's icon

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

Brad Garton's icon
o s's icon

is there a command 'prepend' in lisp? I only know 'cons'...?

ole

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

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

nickv91's icon

@Guillaume Bertrand
@grizzle

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

Christopher Dobrian's icon
Max Patch
Copy patch and select New From Clipboard in Max.
nickv91's icon

thanks christopher :)

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

or use zl group. only on object ;-)