Jump to content
amahabal

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... 

Share this post


Link to post
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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...