Page 1 of 1

Quotes within quotes

Posted: January 7th, 2005, 8:19 am
by byronnash
I am writing a script that writes an applescript file. I borrowed some lines from Impudent's Render and Shutdown script. In the writeLn part, how can I write a line that needs to have quotes in it?
For example if I wanted to write a script line that was "Hello" I would do:
writeLn(""Hello"");

But that doesn't work to have two "s next to each other.

Posted: January 7th, 2005, 9:22 am
by Disciple
Byron

If I'm not mistaken, you need to use the backslash \

Alex

Posted: January 8th, 2005, 3:30 pm
by Impudent1
I would think just using basic nesting quotes should do it without having to escape the character.

ie: instead of " This is " nested " text " which it would interpret as: This is text

use " This is 'nested' text"

you could similarly use 'This is "nested" text'

The key is to keep the single or double quote containers consistant

Posted: January 10th, 2005, 5:30 am
by byronnash
Thanks guys. I was able to use Impudent's advice on some lines.
I have run into something that has me stumped though. I need a line to be written to a file that looks like this
blah blah "Company Name" blah blah

"Company Name" is a variable stored in the prefs

my current script line looks like this
exe_file.writeln('blah blah \" & companyName & \" blah blah');
-or-
exe_file.writeln('blah blah "' & companyName & '" blah blah');

I'm either getting my variable name in quotes or a "0" for the line.

Posted: January 10th, 2005, 1:31 pm
by Paul Tuersley
Either of these should work:
exe_file.writeln('blah blah "' + companyName + '" blah blah');
exe_file.writeln("blah blah \"" + companyName + "\" blah blah");


You can quickly test this sort of thing by adding an expression like this to the Source Text property of a Text layer:
companyName = "byron";
'blah blah "' + companyName + '" blah blah';


Paul T