Quotes within quotes

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

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.
User avatar
Disciple
Posts: 137
Joined: June 5th, 2004, 8:05 am
Location: Los Angeles, CA
Contact:

Byron

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

Alex
Impudent1
Posts: 57
Joined: June 12th, 2004, 6:40 pm

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
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

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.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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
Post Reply