Sorry for nagging, but – as mentioned in my post above – I think you really should quote the KM variables in the snippets:
set myASVar to getvariable myKMVar
gives an error:
: execution error: The variable myKMVar is not defined. (-2753)
→ set myASVar to getvariable "myKMVar"
is fine.
This is because unquoted strings (other than keywords) are seen as variables by AppleScript. And, at that stage, the KM variable is not yet in the AppleScript space.
The same for
setvariable myKMVar to myASVar
should be → setvariable "myKMVar" to myASVar
This concerns the first snippet on “Using AppleScript to Get and Set Keyboard Maestro Variables”. (I have not checked if the error is also present on other articles.)
Sorry for not nagging earlier (), but I became aware of this only as I pointed another user to the WiKi article.
– Tom