Forums > MaxMSP

back slash question.

March 2, 2006 | 3:32 am

Hi, I’m trying to add (back slash) in front of any " mark.

I’m need to send a message which is

event f 1 0 524288 1 "Macintosh HD:loop.aif" 0 0 0

to external called Csound~. But when I send this message
to Csound~, "" didn’t get transfered so I get an errors.

please look at attached file.

it works if I put in front of " then everything is fine
but I don’t want(and I shouldn’t for stand alone issue) do
it manually. So how could I add to " automatically?

thanks for reading the post


March 2, 2006 | 4:21 am

WonSeok wrote:
> it works if I put in front of " then everything is fine
> but I don’t want(and I shouldn’t for stand alone issue) do
> it manually. So how could I add to " automatically?

regexp and careful use of escaping. You’re working with ‘active’
characters ["], so it’s going to look messy. You may also need to
compensate for max-syntax-related transformations after output too.

If you’re constructing the initial message yourself, then sprintf should
work to combine the components and add the necessary syntax. You will
still need to keep in mind what happens to the message after it
re-enters the normal max syntax universe.


March 2, 2006 | 4:25 am

You cannot, generally. This goes for any other programming language
that requires you to escape quotes. There is no way to process a
message/string with an unescaped quote in it because, to the
language’s parser (the thing that turns your code/path into something
that makes sense to the language), the quote is syntax. You need to
escape it to make it part of the message. In Max, quotes are used to
designate symbols (otherwise you’d have to escape every space in a
symbol).

If you need to escape tons of messages like this to load into Max,
I’d suggest you do it in another program and then stick them into
Max. The other alternative is not putting in any quotes at all, and
then inserting them escaped later on by finding all of the bits with
non-numeric characters after "event f" and lumping them together.
This seems like a waste though — Ideally you want to have it done
upfront. Max is not properly equipped to deal with this.

Assuming you have a file full of lines that need quotes to be
escaped, you can do something like this in Io (www.iolanguage.com):

InputFile := File clone openForReading()
OutputFile := File clone openForUpdating()
while(line := InputFile readLine,
OutputFile write(line asMutable replaceSeq(""", "\""))
OutputFile write("n")
)

Other languages offer similar utility.

- John


March 2, 2006 | 9:10 pm

Thanks guys.
I’ll try those methods.


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