Hey Greg,
That's just the way Keyboard Maestro works...
Global variables show up in the variables panel of the Keyboard Maestro Editor if they have been created and not set to %Delete%
.
The variables pref pane does not show variables that exist – it shows the variables it wants to whether they exist or not. (Somewhere on the forum Peter explains this at some length.)
Set a variable:
Variable Existence Tests.kmmacros (2.1 KB)
See the result in the Keyboard Maestro Editor's Variables Prefs:
tell application "Keyboard Maestro Engine"
set variableNameList to name of variables
end tell
Result:
{
"BookTitle",
"DND__gtmbnWindowPosition",
"DND__kmfamResourcesFolderPath",
"DND__kmfamWindowPosition",
"DND__sspResourcesPackagePath",
"DND_CF__TargetFolderPath",
"DND_KM_TEST_MENU",
"DND_MSI_moveToDestinationFolderPathList",
"ENV_PATH"
}
tell application "Keyboard Maestro Engine"
set variableBookTitleExists to exists of variable "BookTitle"
end tell
Result:
true
Set variable to nothing and thereby destroy it:
Variable Existence Tests.kmmacros (2.1 KB)
The variable is in fact destroyed – despite the fact that it still shows up in the Keyboard Maestro Editor's Variables Prefs:
tell application "Keyboard Maestro Engine"
set variableNameList to name of variables
end tell
Result:
{
"DND__gtmbnWindowPosition",
"DND__kmfamResourcesFolderPath",
"DND__kmfamWindowPosition",
"DND__sspResourcesPackagePath",
"DND_CF__TargetFolderPath",
"DND_KM_TEST_MENU",
"DND_MSI_moveToDestinationFolderPathList",
"ENV_PATH"
}
tell application "Keyboard Maestro Engine"
set variableBookTitleExists to exists of variable "BookTitle"
end tell
Result:
false
Destroy the variable AND remove it from the Keyboard Maestro Editor's Variables Prefs:
Variable Existence Tests.kmmacros (2.1 KB)
tell application "Keyboard Maestro Engine"
set variableNameList to name of variables
end tell
Result:
{
"DND__gtmbnWindowPosition",
"DND__kmfamResourcesFolderPath",
"DND__kmfamWindowPosition",
"DND__sspResourcesPackagePath",
"DND_CF__TargetFolderPath",
"DND_KM_TEST_MENU",
"DND_MSI_moveToDestinationFolderPathList",
"ENV_PATH"
}
tell application "Keyboard Maestro Engine"
set variableBookTitleExists to exists of variable "BookTitle"
end tell
Result:
false
You can also test for this with Keyboard Maestro's IF-THEN action:
Variable Existence Tests.kmmacros (6.0 KB)
Personally I don't like the fact that non-existent variables show up in the Keyboard Maestro Editor's Variables Prefs.
Nor do I like the fact that the variables inspector pane is IN the prefs.
But despite a lot of argument and discussion over the years, this is the way Peter has decided to do things – and it's what we have to live with.
Once you accept that and get used to it it's not that big a deal.
-Chris