AnsweredAssumed Answered

Calculated AppleScript - escape character challenge

Question asked by bjbk on Jun 3, 2013
Latest reply on Sep 24, 2015 by bjbk

Hello, All!

I have a challenging nesting issue perhaps we can come up with a solution. I have been working on this for quite a while to no avail. Sometimes staring at a problem for too long...

I have an AppleScript in my solution that manipulates a third party website to automate the task of populating the fields on a form. I have a line of code that works just fine in a native Applescript but I would prefer to use a calculated Applescript for future development reasons.

Here is the piece of native Applescript code:

 

do JavaScript "function testFieldset() {var fieldsetExists = $('fieldset')[1]; if (fieldsetExists) {return \"true\";} else {return \"false\";}} testFieldset();"

The challenge is that Applescript has to use a backslash to escape the JavaScript return "true" and "false" code. I tried single quotes, \\"" and even the Quote () function but I'm still getting an error in the script as I just can't seem to wrap my head around the proper escape syntax to accomplish this.

 

"do JavaScript \"function testFieldset() {var fieldsetExists = $('fieldset')[1]; if (fieldsetExists) {return " & Quote ( "\"true\"" ) & ";} else {return \\""false\\"";}} testFieldset();\""¶

 

Perhaps someone has been through this before.

Thanks for any help!

Outcomes