Forums > MaxMSP


Nov 25 2011 | 10:39 am

Is there an object that makes it easy to change the verb on any message?



eg, [set "Some Text"] -> [remessage append] => [append "Some Text"]

Kind of like prepend, only it lops off the first element before prepending.

It’s not hard to write such an object in javascript, but I wondered if it already exists?

Nov 25 2011 | 11:11 am

You don’t need to look very deep – a simple combination of [zl] and [prepend] will do the job:

-- Pasted Max Patch, click to expand. --

Nov 25 2011 | 12:30 pm

Thanks for the quick reply.
This almost works, but it fails when the first argument is a message recognized by [prepend], like "set"

-- Pasted Max Patch, click to expand. --

Here I have text coming out of a textedit box going into [zl slice 1] -> [prepend append] -> [print]. The text in the box is "set me the stoops of wine upon that table".

Because it starts with "set", this text never makes it to [print]. And now the next thing I send down the pipe will not be prepended with "append", but with "me the stoops of wine upon that table"!

I think I need an object that removes the old verb and prepends the new one in a single step, so my text never has a chance of being interpreted as a message.

Nov 25 2011 | 3:14 pm

or [substitute]

-- Pasted Max Patch, click to expand. --

Nov 25 2011 | 3:59 pm


My example works just fine on its own – it doesn’t fail when the first argument is "set" (it works perfectly when the first argument is "set"), but it fails because of [textedit]’s particular behaviour (of prepending ‘text’ to the output) just like DEvo pointed out, in which case just follows DEvo’s comments to fix it. :)

Nov 26 2011 | 3:48 am

@DEvo, @laonikoss

I think we’re misunderstanding each other. I don’t want to slice off the "set". I want to turn the output of the [textedit] — text set me the stoops of wine upon that table — into an append statement — append set me the stoops of wine upon that table. When I said the first *argument* was "set", I meant the second term in the sequence, the first term ("text") being (I think this is the right max lingo) the "message".

[route text] -> [prepend append] fails the same as [zl slice 1] -> [prepend append], by inadvertently sending a "set" message to [prepend].

[route text] -> [zl slice 1] -> [prepend append] would work in this case, but it’s not what I want to do (and it *would* fail if the text was, say, "please set the table").

Looking back I see I confused the issue because my original example did involve substituting "append" for "set" (set "Some Text" ==> append "Some Text").


[substitute] is exactly what I’m looking for, thanks. Specifically, [substitute text append 1] (the 1 prevents unwanted substitutions if "text" occurs somewhere in the text).

Viewing 6 posts - 1 through 6 (of 6 total)

Forums > MaxMSP