When I use a local variable in the Execute AppleScript action I use this:
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set myAppleScriptVar to getvariable "Local__myVar" instance kmInst
end tell
But in this case, since I'm just setting 1 variable, I can do this, right?
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine" to set myAppleScriptVar to getvariable "Local__myVar" instance kmInst
adding the to before set and then removing end tell, right?
I would only use the first version if I'm setting 2 or more variables?
Me personally, I try to use one-liners everywhere I can. The only time I don’t is when necessity warrants it (the tell block having more than one command for instance) or when a one-liner would be so long that reading it would be difficult due to it extended out of view.
Thanks for checking and glad that this is the way to do it.
For this you could use that symbol to continue on the next line, right? I don't know what it's called or even how to add it, but I've seen it and I have some scripts that have them.
I also don't know if there are rules for them when it comes to where in the line you can add them or you can't.
I can’t remember the name of the said character either but a simple rule is that you can place it when ever there is a break from the standard syntax in AppleScript like the normal quotation if I remember it correctly… but be careful this rule may vary a lot if you embed shell commands with or without the quoted form of text concenating ….
You can also place it in front of the normal open bracket „(“
My advise is to use Script Debugger instead of Apple’s Script Editor … it has - if I remember it correctly - a feature build in to auto correct it if you make mistakes on using this character.
Even though in non paid version you will get far more power for developing AppleScript and AppleScript Objective-C code as with Script Editor. But I have Version 7 as paid Version and plan to buy version 8 as well. The 100$ it costs is worth every penny
Press Option-Enter to create the line break symbol:
set kmInst to system attribute "KMINSTANCE"
tell application ¬
"Keyboard Maestro Engine" to set myAppleScriptVar ¬
to getvariable "Local__myVar" instance kmInst
There are rules, but I don't recall what they are. If you try to put one in a spot it won't allow it to be used, though, I think it'll move it somewhere it can (maybe)? All I know for certain is that I've never broken a script by adding line break characters.