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?
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);
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?
Copy link to clipboard
Copied
InDesign 2020 and High Sierra
Copy link to clipboard
Copied
Does this compile?
tell application "Adobe InDesign 2020"
do script "alert(\"Hi\");" language javascript
end tell
Copy link to clipboard
Copied
Sadly, no. Must be macOS Catalina, then?
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.
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!
Copy link to clipboard
Copied
I'm having the same issue with 10.15.7
Copy link to clipboard
Copied
I am as well.