Friday, June 23, 2017

#1 2005-10-11 03:04:22 pm

julifos
Administrator
From: MalasaƱa, Madrid
Registered: 2002-11-20
Posts: 2014

Should I use scripting additions?

AppleScript's dictionary is large, but not always large enough. Sooner or later you will probably find yourself up against something that AppleScript just cannot seem to do...that's when it's time to look for a scripting addition to get the job done.

Think of a scripting addition (or OSAX) as just a means to add an extra word, or many words, to the dictionary.
A few examples: Email osaxen allows you to send email with AppleScript without ever launching an email program. Satimage OSAX contains trig functions. AutoType OSAX (MacOS) lets you "type" characters and simulate keyboard actions (like Command-Shift-3 to take a screenshot).

Other osaxen just make life easier. For example, ACME Script Widgets contains a command called "Tokenize" which parses text without the confusion of Apple's text delimiters. As an example:

Applescript:

set the_text to "Vacation.jpg "
set break_it_up to tokenize the_text with delimiters "." -- returns {"Vacation", "jpg"}
set no_extension to item 1 of break_it_up -- returns "Vacation"

Any scripting addition you use would have to be installed on any machine your script would run on, but this is a small price to pay for the functionality they extend to AppleScript.

AppleScript's purists will allways tell you to use "vanilla" solutions if you can (use plain AppleScript statements, without the help of osaxen or third-party helpers), which are allways more easy to mantain-update and highly portables. However, some times the only way is the use of a scripting addition for many reasons: power (eg, complex search-replace operations), speed (eg, calculations with binary digits), functionalities (eg, use advanced User Interface objects, such as progress bars)...

Please, note that if you distribute scripts using osaxen commands, you must instruct your users to install the related scripting additions. Otherwise, those commands won't be available for your scripts.

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.045 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)