Pushing List Items

Apr 11, 2013 at 8:48am

Pushing List Items

Hello, I hope someone here can help me. What I am trying to do is for each time a key is press, the key code for that key is added to the end of an ongoing list of pressed keys. I think I need to used something like zl join to get this to work, but I’m not having much luck yet. I have some experience with things like javascript but I’m having a hard time wrapping my mind around Max. My snippet is pasted here. Thank you!

– Pasted Max Patch, click to expand. –
#67626
Apr 11, 2013 at 9:28am

yes, it’s possible with [zl join].

here’s a couple of ways of doing it (the difference being that the [zl] solution will remember what has been stored already even if you delete the message box, whereas the [append] solution only adds the last typed number to the list, so it will “reset” if you clear the message box).

– Pasted Max Patch, click to expand. –

(these add the new numbers to the beginning of the list – if you want to add the numbers to the end of the list, change [append] into [prepend], or add a [zl rev] before the message box in the [zl] example)

#243363
Apr 11, 2013 at 9:30am

Here is one way with a dirty hack.
The reason of the use of the “_” is that there is that zl doesn’t handle empty lists. There are for sure other ways to do it.

– Pasted Max Patch, click to expand. –
#243364
Apr 11, 2013 at 11:35am

Can also be done with [zl queue], if you don’t need continuous output of the list.

– Pasted Max Patch, click to expand. –
#243365
Apr 11, 2013 at 3:54pm

Wow, you guys are fantastic. Thank you so much!

#243366

You must be logged in to reply to this topic.