|
|
10.4: Pass command-line arguments to AppleScript
Here is a trick I learned from the ORA AppleScript book to pass args into a compiled AppleScript that works with all versions of OS X.
In a Bourne style shell do this (in csh style shells do a setenv):
Now at the beginning of the AppleScript add this:
The "system attribute" corresponds to the environment variables, so what you are doing is passing an argument as an environment variable. You can now use this_foo in your script to get your passed value. In practice the overhead involved with accessing a separate AppleScript file and using the system extension to extract the value of the environment variable takes more time than compiling a SHORT AppleScript so keep this in mind. You will only see a speed increase for your longer AppleScripts, the ones that take a longer time to compile.
10.4: Pass command-line arguments to AppleScript
Can the Terminal script ("% osascript a.scpt world") be saved as an application, so double-clicking it will run it? |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.08 seconds |
|