0

I've created a large number of TextExpander snippets but with the wrong font. Using AppleScript I want to change the font of all rich text expansion of the snippets in a group using the following script:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "TextExpander"
    repeat with s in snippets of group "Math"
        set font of rich text expansion of s to "ArialUnicodeMS"
    end repeat
end tell

Using either Apple's on script editor or the Script Debugger of Late Night Software, I can enumerate the snippets fine. But I can't change the font property, while the TextExpander dictionary clearly indicates that the font property has a 'get' and 'set' operation.

But in the debugger the property I see a small "read only" icon (a pencil with a red diagonal line through it)

Am I doing something wrong or, better, what do I do wrong?

nanitous
  • 681
  • 7
  • 17
  • Using _Script Editor_, what happens when you run your script. If it errors, what is the error ? Also, check what sort of value it is expecting by first retrieving the `font of the rich text expansion of every snippet in group "Math"` to a) make sure the getter works, for if it fails, then the reference is probably wrong; and b) make sure it **is** just a simple string value with the name of a font, rather than, say, a record containing the name, size, style, weight, etc. of the font. – CJK Dec 18 '19 at 02:25
  • CJK’s troubleshooting advice is solid, to which I’ll add: application dictionaries can and do sometimes lie. Sometimes you have experiment by way of educated guesses and trial-and-error till you stumble on the right incantation/conclude it cannot be done. It would also help to update your original question with the full error message and any other details that may help diagnose from a distance. (One other tip: it *should* be enough to say `set font of rich text expansion of snippets of group "Math" to "FONTNAME"`; no loop needed.) – foo Dec 18 '19 at 21:19
  • @CJK About _errors_. Well, that is the thing: no error message of any kind are return. The assignment with `set to` simply doesn't happen. About the _type_: It is very easy to retrieve the font name; and that value is unequivocally a string (displayed as "text", and in AE format `ctxt`. I determined the type by assigning the value of `font of ....` to a local variable, say f, and returning `class of f`. – nanitous Dec 19 '19 at 14:35
  • @foo, About lying dictionaries; It looks a bit like that indeed. About the _full error message_ there is none, the assignment simply doesn't happen. I hesitate a bit accusing the dictionary from lying to me because the dictionary and Script Debugger during debugging show properties that are indeed read-only (get) and properties that are, putatively, read-write (get/set). I experimented with setting other get/set properties of a snippet, e.g. "abbreviation mode" and that works. With regard to your one liner: nice, that works I'm now reach out to Smile Software, hoping they can help. – nanitous Dec 19 '19 at 15:16

0 Answers0