Trivial comparison calculation problem

Please rescue me from my befuddlement. My macro executes an AppleScript that returns the name of the front process and saves it in the variable result. I want to see if result is `TextEdit in a Calculation Condition. What do I put in that condition? Seems trivial but I can’t get it to work

Hey Mitchell,

Calculate is for numerical operations.

There's no need to use AppleScript to get the name of the front app.

Generic-Test 01.kmmacros (2.5 KB)

Of course you can always do something like this in AppleScript:

----------------------------------------------------------------
tell application "System Events"
   set procName to name of first process whose frontmost is true
end tell

if procName = "TextEdit" then
   beep
end if
----------------------------------------------------------------

-Chris

Ah, good. I’m too used to using my usual AppleScript techniques. I have to learn to stop and think if there’s a KM way to do something simple that I could do in AppleScript.

“Calculation” seemed the natural choice for a condition when I was thinking “equality”.

The reason I took the apparently silly approach of doing part in KM and part in AS is that I had envisioned multiple decisions based on the application name. If all I wanted was to test one equality, then sure, your AS was what I would have written. (Although because I wanted to perform KM actions if the application was TextEdit, I would have written

tell application "System Events" to ¬
    (the name of first process whose frontmost is true) is "TextEdit"

There’s a whole discussion on Comparing Strings. I read only part of it before giving up thinking it had nothing to do with string equality, but I guess it does.