Highlighted

AppleScript 'do script' no longer works with InDesign CC 2020?

Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Dear Community,

 

I'm trying to launch Javascript/ExtendScript from AppleScript in recent InDesign using "do script" command. Is that still possible? I'm getting errors as if the command is no longer valid

 

tell application "Adobe InDesign 2020"
    activate
    set jsx_script to "Macintosh HD:Users:xxx:project:script.jsx"
    set val_1 to "Foo"
    set val_1 to "Bar"
    set my_values to {val_1, val_2}
    do script jsx_script language javascript with arguments my_values
end tell

 

This generates a syntax error at the `do script` line: "Expected end of line, etc. but found “script”."

 

Any ideas?

Topics

Scripting

Views

150

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

AppleScript 'do script' no longer works with InDesign CC 2020?

Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Dear Community,

 

I'm trying to launch Javascript/ExtendScript from AppleScript in recent InDesign using "do script" command. Is that still possible? I'm getting errors as if the command is no longer valid

 

tell application "Adobe InDesign 2020"
    activate
    set jsx_script to "Macintosh HD:Users:xxx:project:script.jsx"
    set val_1 to "Foo"
    set val_1 to "Bar"
    set my_values to {val_1, val_2}
    do script jsx_script language javascript with arguments my_values
end tell

 

This generates a syntax error at the `do script` line: "Expected end of line, etc. but found “script”."

 

Any ideas?

Topics

Scripting

Views

151

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Mar 26, 2020

Copy link to clipboard

Copied

You haven’t defined val_2—val_1 is set to "Foo" and "Bar". The error is being generated from something in the JS you are calling.

 

This works for me:

 

 

tell application "Adobe InDesign 2020"
	activate
	set jsx_script to "...Desktop:HelloWorld.jsx"
	set a to "Foo"
	set b to "Bar"
	set my_values to {a, b}
	do script jsx_script language javascript with arguments my_values
end tell

 

 

The HelloWorld JS:

 

var a1 = arguments[0];
var a2 = arguments[1];

alert(a1 + "  " + a2);

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Hi Rob,

 

Thanks. val_2 was just an omission on my part while pasting the code here. The problem I'm having is AppleScript console throws an error when I want to use "do script" command. Only when I comment it out then I can save the script. May I know the macOS version and InDesign version you're trying it on?

 

Screenshot 2020-03-26 at 16.36.11.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Mar 26, 2020

Copy link to clipboard

Copied

InDesign 2020 and High Sierra

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Mar 26, 2020

Copy link to clipboard

Copied

Does this compile?

 

 

tell application "Adobe InDesign 2020"
	do script "alert(\"Hi\");" language javascript
end tell

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Sadly, no. Must be macOS Catalina, then?

 

Screenshot 2020-03-26 at 18.26.36.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Mar 26, 2020

Copy link to clipboard

Copied

Probably. There does seem to be a lot of AS problems with Catalina. I’m seeing some apps abandon their AS support—the latest version of Fetch is no longer scriptable.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

Happy to report the above works after upgrading to macOS 10.15.4!

 

So the issue was definitely Catalina 10.15.3 – not sure about earlier.

 

Phew!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...