String quotes

1 view
Skip to first unread message

Ashley Chapman

unread,
Nov 9, 2010, 8:06:42 AM11/9/10
to exodus...@googlegroups.com
I've been doing a lot of html/JavaScript code generation recently (with Scarlet/QM), and it's been a right royal pain defining a string with both quote types, when you need to enclose the whole thing in quotes.  For some reason I looked in the QM manual, and discovered that you can use backslash ( eg \string\ ) as an alternative quoting character.  Suddenly, all of the quote shenanigans becomes much simpler.

Is there any possibility of doing the same in Exodus?

--
Ashley Chapman

Steve Bush

unread,
Nov 9, 2010, 9:40:23 AM11/9/10
to exodus...@googlegroups.com
Exodus hasnt got a compiler or precompiler of its own. It uses any standard C++ compiler so I cant implement QM's trick.

Cant you use the almost universal backslash houdini trick?

This is valid javascript .. and valid exodus too.

var aa="I said \"Hello\" first!";

Exodus can do the following too thanks to C++ compiler's penchant for joining adjacent strings.

var aa="This is a line of text\n"
          "and so it this\n"
          "and so it this\n"
          "and so it this\n"
          "and so it this\n";

--
You received this message because you are subscribed to the Google Groups "Exodus Users" group.
To post to this group, send email to exodus...@googlegroups.com.
To unsubscribe from this group, send email to exodus-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exodus-users?hl=en.

Ashley Chapman

unread,
Nov 9, 2010, 10:14:12 AM11/9/10
to exodus...@googlegroups.com
On 9 November 2010 14:40, Steve Bush <neosys.com@gmail.com> wrote:
Exodus hasnt got a compiler or precompiler of its own. It uses any standard C++ compiler so I cant implement QM's trick.

Cant you use the almost universal backslash houdini trick?

This is valid javascript .. and valid exodus too.

var aa="I said \"Hello\" first!";

Exodus can do the following too thanks to C++ compiler's penchant for joining adjacent strings.

var aa="This is a line of text\n"
          "and so it this\n"
          "and so it this\n"
          "and so it this\n"
          "and so it this\n";


I'm thinking of outputting this string:-
<input type="button onclick="alert('Are you\nSure?')">

which comes

var aa="<input type=\"button onclick=\"alert('Are you\\nSure?')\">

So I have to be particularly careful with the escaping of the \n so it gets enclosed in the string and passed to the browser.

I guess it's allright.  I was just wondering if Exodus had overloaded some operators to make things easier/simpler/cleaner?




 Ashley

Steve Bush

unread,
Nov 9, 2010, 2:28:47 PM11/9/10
to exodus...@googlegroups.com
Sorry no can do. C/C++/Javascript has problems quoting itself and you end up the notorious double, quadruple and even octo slash with only three levels of quoting. btw, if QM allows quoting with a backslash doesnt that cause problems quoting \n etc?

Reply all
Reply to author
Forward
0 new messages