remessage?

skot's icon

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

incoming:

outgoing:

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?

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

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

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

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

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.

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

or [substitute]

laonikoss's icon

@skot

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. :)

skot's icon

@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").

@seejayjames

[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).