AppleScript "setvariable" syntax requires double-quotes around variable name?

I was tearing my hair out for the past hour trying to figure out why I kept getting AppleScript "variable not defined" errors when trying to use the setvariable option, as explained in the AppleScript documentation on the wiki.

I ended up figuring out that I had to enclose the <KM Variable Name> in double quotes in order for it to work. This syntax is not shown in the usage syntax on the Wiki, which may be confusing for people like me who aren't fluent in AppleScript syntax, and only use it on an ad hoc basis for esoteric needs withiin KM.

Keyboard Maestro variable names (and values) are strings.

In AppleScript syntax, a string (or "Text" type instance) is enclosed in double quotes.

See, for example:

AppleScript Literals and Constants :: Text

AppleScript language guide :: Variables and Properties

1 Like

That makes sense to me now, thanks.

That said, if there are no other exceptions to the varname syntax in which you wouldn’t use quotes, it seems to me that the documentation should accurately show the correct syntax, and not make any assumptions that the reader already understands all of the nuances of both KM and AppleScript syntax.