Generate symbols with double backslashes
I'm trying to generate some symbols for use in a sql query. I'm using sprintf to combine the requireed sql syntax with some programatically generated field names and data. To get it (FINALLY!) to work, i just need to do a simple thing: convert a message box like
"F2, F3, F4"
to a message box like
"F2\\, F3\\, F4"
The quotes are in the message box, that is, it is a single symbol. i have tried using sprintf to generate the double backslashes, can't seem to get it. Also tried adding a regexp object [regexp , @ substitute ,\\] after the springf to insert the double backslashes. No dice. I rrrrealy hate escape characters in max, don't understand what is going on.
Attached is an example. Any help appreciated, I'm at this all day!
Oh Yes it can be very frustrating, getting Max and Symbols do what one wants.
Have a look in the patch.
What the? i did try adding 3 and even 4 backslashes to the regexp statement (no joy), but 10 !!?? How does that work, and how did you know to try that? ... and thanks BTW!
Also wondering why you need to remove the message window between regexp and tosymbol to make it work?
Honestly, I found that a good while ago by try and error, watching how max removes backslashes
and other "special" sybols that have behaviour unique to max, when they pass from
one max object to another.
Problems are preprogrammed when You try Windows double backslash style path, or unix commands
to shell or java excuted commands.
So to make it short, the result is not the same if You send a symbol to a message, text object,
or any other max objects. They all react differently.
I have been using a lot atoi - itoa combinations to deal with symbols.
Or using value objects to store symbols, which leaves them in original state.
At some complicated projects i found it easier to store data in text objects,
manipulate them from max using shell and Unix text processing , instead of
doing it in max.
The basic rule of thumb is that each time a message gets parsed, you lose half the backslashes (every odd backslash is interpreted as an escape character, allowing the following, even, backslash to pass through to the next time the parser gets its hands on the message).
The tricky thing is figuring out how many times a message will be parsed. It's not obvious (at least not to me).
But basically, keep on adding (or doubling) backslashes until you get the result you need.