RE: escaping backslashes

Good catch. I don't think there is actually anything wrong with the Ruby script. There are some confusing interactions between Max, Java (ajm.ruby is Java), and Ruby. By the time we get to the Ruby script, the "\r" in "\relative" is being interpreted as a "return feed" character rather than a separate "\" and an "r". So this is a much deeper problem.

A potential workaround is to add this line to the top of the notate def:
str.gsub!("\r", "\\r")
But this will only fix the specific problem you mentioned. I think you will run into further issues if you need to use a backslash for other LilyPond commands. Probably the best solution for now is to use the extra backslash like you are doing.

Perhaps a regexp object could be used in the Max patch to replace "\" with "\\" but I can't seem to get that to work. I'll investigate if I can make some adjustments to ajm.ruby to prevent this, but the obvious solution (replace "\" with "\\" before passing things to Ruby) does not work either! Argh! The problem may ultimately lie with how textedit/Max handles backslashes.

And you are right, there's no particular reason to use Ruby for this, I was just testing out my ajm objects when I made this patch. Terminal scripting could work too.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
You must answer the following question to post. This prevents automated spam submissions. If you answer incorrectly, a different question will be provided so you can try again.
low_ass: