remessage?

Nov 25, 2011 at 10:39am

remessage?

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?

#60195
Nov 25, 2011 at 11:11am

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. –
#216700
Nov 25, 2011 at 12:30pm

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.

#216701
Nov 25, 2011 at 3:14pm

or [substitute]

– Pasted Max Patch, click to expand. –
#216702
Nov 25, 2011 at 3:59pm

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

#216703
Nov 26, 2011 at 3:48am

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

#216704

You must be logged in to reply to this topic.