Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is AppleScript broken?

Explorer ,
Oct 12, 2020 Oct 12, 2020

Catalina 10.15.7 and ID 15.1.2

All of the Applescript sample i've tried crash with errors

Simple scripts like

tell application "Adobe InDesign 2020"
set mySelection to selection
set myCharacterStyle to character style "Italics"
set applied character style of item 1 of mySelection to myCharacterStyle of active document
end tell
 
crash with error message
Invalid key form
on 
character style "Italics"
TOPICS
Scripting
515
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

Two of the lines in your code return errors. Try this:

 

tell application id "com.adobe.indesign"
	set mySelection to selection
	
	--set myCharacterStyle to character style "Italics" 
	--error: Can’t get character style \"Italics\"." 
	
	set myCharacterStyle to (every character style of active document whose name is "Italics")
	
	--set applied character style of item 1 of mySelection to myCharacterStyle of active document
	--error "Adobe InDesign 2020 got an error: Invalid value for set property 'applied character style'. Expected character style or string, but received nothing."
	
	set applied character style of item 1 of mySelection to item 1 of myCharacterStyle
end tell
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 12, 2020 Oct 12, 2020

this gives an error:
Expected “from”, etc. but found property.
on the word "style" in 

(every character style of active document whose name is "Italics")

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

You can also use object reference, this should work:

 

tell application id "com.adobe.indesign"
	set mySelection to selection
	set myCharacterStyle to object reference of character style "Italics" of active document
	set applied character style of item 1 of mySelection to myCharacterStyle
end tell
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 12, 2020 Oct 12, 2020

this gives an error:
Expected end of line, etc. but found “reference”.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2020 Oct 12, 2020

There do seem to be many problems with AS on Catalina—can’t help I’m using High Sierra. The script in your first post does not compile on HS (my examples do). There aren’t many AS scripters here, so you might check at macscripter

 

https://macscripter.net/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 12, 2020 Oct 12, 2020
LATEST

thanks for trying

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