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)
![Keyboard Maestro Export](https://forum.keyboardmaestro.com/uploads/default/original/3X/e/5/e5c9f3394cd84d660b5173a6222a62e30ee1141d.png)
See the result in the Keyboard Maestro Editor's Variables Prefs:
![image](https://forum.keyboardmaestro.com/uploads/default/original/3X/2/c/2cb380878e7ef4ef41985428307802a75582ed94.png)
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)
![Keyboard Maestro Export](https://forum.keyboardmaestro.com/uploads/default/original/3X/2/3/2378c6e77d16a167b85f0b3a0c611a65708f0b94.png)
The variable is in fact destroyed – despite the fact that it still shows up in the Keyboard Maestro Editor's Variables Prefs:
![image](https://forum.keyboardmaestro.com/uploads/default/original/3X/3/0/305a3d4c7da227764641b912de09d6181a33d56a.png)
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)
![Keyboard Maestro Export](https://forum.keyboardmaestro.com/uploads/default/original/3X/5/9/590e93729ad5a147ebbe3bb309f139170f72fbe3.png)
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)
![Keyboard Maestro Export](https://forum.keyboardmaestro.com/uploads/default/original/3X/9/5/9572c11bbc42132d049db5204b2996247d5d5d48.png)
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