Skip to main content
Inspiring
June 12, 2009
Answered

DoScript Turducken ?! [JS] [AS]

  • June 12, 2009
  • 2 replies
  • 1548 views

Is there any other way, besides storing a string value into a script argument to run a  do script turducken style?

This works, although highly impractical I'm still curious how to do it in one line...

tell application "Adobe InDesign CS3"

    tell script args
        set value name "my_applescript" value "display alert \"DOSCRIPT TURDUCKEN\""
    end tell
    do script " var my_applescript = app.scriptArgs.getValue(\"my_applescript\");app.doScript((my_applescript), ScriptLanguage.applescriptLanguage);" language javascript
   
end tell

If declare a string value within a statement that already has escaped quotes, it results in the  error: unterminated string constant.

~mike

This topic has been closed for replies.
Correct answer D¡rk Becker

You need to quote your applescript literal, with one level of escapes.

tell application "Adobe InDesign CS3"

do script " var my_applescript = \"display alert \\\"DOSCRIPT TURDUCKEN\\\"\";app.doScript(my_applescript, ScriptLanguage.applescriptLanguage);" language javascript

end tell

Dirk

2 replies

D¡rk BeckerCorrect answer
Inspiring
June 14, 2009

You need to quote your applescript literal, with one level of escapes.

tell application "Adobe InDesign CS3"

do script " var my_applescript = \"display alert \\\"DOSCRIPT TURDUCKEN\\\"\";app.doScript(my_applescript, ScriptLanguage.applescriptLanguage);" language javascript

end tell

Dirk

Jongware
Community Expert
Community Expert
June 12, 2009

(Disclaimer: No AS man!)

Perhaps the escaped quotes need double escaping: \\\" (NOTE: Three backslashes!)

First way round, it gets parsed into the literal string \", second time it gets parsed into a single "

[Post-edit thought] [Actually, Pre-post!] What is "Turducken"??

RandomsenAuthor
Inspiring
June 12, 2009

Turducken is a horrible culinary creation where a Chicken is shoved inside of a Duck, and those two are shoved inside a Turkey and cooked all together.

tell application "Adobe InDesign CS3"

    do script " var my_applescript = display alert \\\"DOSCRIPT TURDUCKEN\\\";app.doScript((my_applescript), ScriptLanguage.applescriptLanguage);" language javascript
   
end tell

This gives me "Adobe InDesign CS3 got an error: Expected: ;"

Harbs.
Legend
June 15, 2009

Randomsen wrote:

Turducken is a horrible culinary creation where a Chicken is shoved inside of a Duck, and those two are shoved inside a Turkey and cooked all together.

Yuck! Who thinks up these absurd creations?