• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Run script with arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Run script with arguments


  • Subject: Re: Run script with arguments
  • From: Chris Page <email@hidden>
  • Date: Fri, 16 Jan 2015 05:22:09 -0800

To elaborate and confirm:

The AppleScript runtime supports "callbacks" that enable the host application to interact with and observe what it's doing. In particular, there's a callback that enables hosts to watch every Apple Event being sent by scripts to applications. Script Editor uses this to record events in the Log.

The Open Scripting Architecture (OSA) technology upon which AppleScript is founded supports multiple instances of a given scripting-language runtime "component". Each component instance has its own set of callbacks.

As a development environment, Script Editor places each script into its own component instance, it's own instance of the script runtime. This provides some separation so script documents don't interfere with each other. Script Editor knows about each of the instances it has created, and it installs callbacks into each of them.

"run script" works by executing the script in a particular instance of AppleScript, which Script Editor is not using and in which it has not installed its callbacks.

"log" is just one more event that Script Editor logs via the callback mechanism and is not treated specially. You'll either see events being logged or not.

Pro Tip: Actually, "log" is a little bit special. You can explicitly suppress "log" events from being logged by Script Editor with the "start log" and "stop log" commands. If you "stop log" more times than you "start log", log events are not recorded in Script Editor's Log. You can use this to suppress or enable logging for portions of a script's execution, e.g.,

log 1
stop log
log 2
start log
log 3

The event log for this script is:

(*1*)
(*3*)

-- 
Chris Page
The other, other AppleScript Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Permitting a script to only run on OS X Yosemite
  • Next by Date: Script libraries
  • Previous by thread: Re: Yosemite and activate failures
  • Next by thread: Script libraries
  • Index(es):
    • Date
    • Thread