Jump to content

Do variables behave differently in NSAppleScript vs AppleScript


Recommended Posts

In a workflow, I had an NSAppleScript containing this line:

set thePerspective to system attribute "DESIRED"

I then also added a display dialog to show the value. I was getting nothing. I added a debug before that, and sure enough, the variable was set.

 

I then replaced NSAppleScript with RunScript with OSAScript as the language, and no other changes (except, of course, "on alfred_script" --> "on run"), and it worked fine.

 

Any ideas what is going on here?

 

I had assumed the two to be drop-in replacements... 

Link to comment
4 hours ago, amahabal said:

Any ideas what is going on here?

 

I had assumed the two to be drop-in replacements... 

 

Run NSAppleScript executes your code in Alfred's own process, on its main thread, so it shares Alfred's own environment. Run Script executes your code in a separate subprocess, so Alfred can manipulate the environment it runs in (i.e. adding workflow variables to the environment).

 

Basically, just don't use Run NSAppleScript. Because it runs on Alfred's main thread, it blocks Alfred while the code is running (Run Script doesn't). And it behaves weirdly, too.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...