The reason I like to use the KM Action option to "return results to variable" is that it makes it easy, and less error prone, for the user to set the KM variable of their choice. There are many scripts that are general purpose, like choosing file and folder, and I think it is best for the user to not have to change the script to set a different KM variable.
Due to the nature of Keyboard Maestro, I don't think I'd write any process using it that is truly mission critical. Of course, Peter might disagree with me.
No, I think Peter would agree. KM meets a particular need, and meets it extremely well, but checking a heart monitor or giving a "Go/No Go" on a launch are probably not in its scope.
First, @JMichaelTX thanks for sharing your template. I also appreciate the discussion regarding the pros and cons of each approach.
The V4.1 template works perfectly on my MacBook Pro 16" (Big Sur 11.3.1 using KM 9.2).
On my Mac mini (Late 2012) (Mojave 10.14.6 also using KM 9.2), however, the template returns:
~~~ VARIABLE from Script Results ~~~
objc[1049]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fff9d1323f0) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x110386f50). One of the two will be used. Which one is undefined.
/Users/j/Desktop/
Note, if I copy the AppleScript code to the Script Editor, I get the expected:
~~~ VARIABLE from Script Results ~~~
/Users/j/Desktop/
It is a warning the system puts out because Apple chose to implement a specific class, FIFinderSyncExtensionHost, in both of two different Apple Frameworks, both of which happen to be used in this process (indirectly, they are private frameworks so not used directly).
It is essentially an Apple bug, though hopefully harmless (assuming both implementations are identical, otherwise it could have interesting quirky bugs).
Presumably Apple resolved the bug between Mojave and Big Sur which is why you don't see it in Big Sur, thus no need to turn off âInclude Errorsâ - note that Include Errors chooses whether the output of the script is just the stdout, or also includes stderr error stream.