OSA Components Release Notes

Version:  1.3.0


Requirements:

Mac OS X 10.6 minimum

Introduction:

The OSA components included in this release enable scripting languages like Perl, Python, Ruby, sh, and Tcl to work in the OSA environment at peer level with AppleScript. As such, scripts in any of the supported languages can be saved in various formats including scripts (.scpt), script bundles (.scptd), and application bundles (.app). They may be run in all the usual circumstances such as from a script editor application, from the Scripts menu on the main menu bar, or by using 'osascript' in Terminal.

When saved as applets or droplets, they may be double-clicked to run or process file objects dropped on them just as similar applications using the AppleScript language. When saved as scripts, or script bundles, they may run by applications that have scripting support.

The examples included in this distribution do not purport to be tutorials or language showcases. Their intent is merely to provide convenient double-clickable starting points. One thing to note is that if you are learning one of these more or less shell-oriented languages, their viability in the OSA environment supported by the Script Editor and Script Debugger applications can provide you with a more pleasant and convenient environment to work with than in Terminal.

Translations:
French  German  Italian  Japanese  Portugese  Spanish
Installation:

To ensure a successful installation:

  1. Quit any active OSA script editors and any applications or processes which may be using previous versions of these components.
  2. Decide whether to place the new OSA components in the /Library/Components or ~/Library/Components folder of your startup disk. Normally you'll want to install them in the ~/Library/Components folder as administrator privileges are not required.
  3. If the designated Library folder does not exist, drag the Components folder from the install disk to the designated Library folder.
    If the designated Library folder already exists, trash the components which are to be replaced, then drag the new components from the Components folder of the install disk into it.
  4. Restart (optional but recommended).
License:

These OSA components are for personal non-profit use only and you must agree to the conditions of the included OSABridgeLicense.pdf file to use them. Other licenses at reasonable fees are available.

Download:

OSAComponents 1.3.0 for Mac OS X Snow Leopard

Usage:

To use one of these languages in Apple's Script Editor application, choose the language from a window's Navigation bar popup menu:

[choice.png]

A similar facility is available in Late Night Software's Script Debugger application.
Once a language is selected, type in your script. Edit, run and save as usual.

Look in the ExampleDroplets and ExampleMailRules folders in the distribution for simple examples in each supported language.

Language map for supported components
Component NameLanguage NameLanguage Code
PerlOSAperl'PLSA'
PythonOSApython'Py-c'
RubyOSAruby'RBSA'
ShOSAsh'SHSA'
TclOSATcl'Tcl '

Terminal:

To run a previously compiled script or script bundle from Terminal:

osascript /path/to/my.scpt
osascript /path/to/my.scptd

To run a dynamically compiled script in Terminal using one of these OSA languages, supply the language option and set the other options as desired.

For a Perl script use:

osascript -l perl -e 'print( $ENV{HOME} );'

You may also use a here document:

osascript -l ruby << EOSCRIPT
@var = "Hello world!"
puts "#@var"
EOSCRIPT

osascript -l sh << EOS
cd;
ls -laFG
env|sort
EOS

To compile a script in Terminal using one of these OSA languages, supply the language option and set the other options as desired.

osacompile -l Tcl -o tclcmds.scpt -e 'join [lsort [info commands]] \n'

osacompile -l python -o py.scpt << EOS
import os, sys, site;
var = os.environ['HOME'] + "/Desktop/";
print( var );
EOS

You may embed calls to any of these OSA components in an AppleScript.
For example, to call 'perl' from an AppleScript in Script Editor use:

run script "$var=`env|sort`;print( $var );" in "perl"

Errors:

There are several types of errors which may occur.

Some are the result of errors in your scripts (both compile time and runtime). These are normally reported in a dialog in the host scripting application.

Sometimes you may encounter two error dialogs with roughly the same error message. These will be the result of these OSA component's over-zealous error mechanisms. You'll normally only have to fix one error in cases like that.

Then there are internal errors that may report error numbers outside the range of typical AppleScript errors. These could be the result of a faulty or corrupt installation. If you every receive errors that have errors in the range of low level system APIs, you'll probably have to restart the machine. These types of errors usually come from over-stepping the bounds of strings, lists, and other such objects in a repeat loop in the actual scripting language and these OSA components may not be able to overcome a hang in the scripting language.

Author:

Philip Aker

Web Site:

OSA Components


Enjoy,

Philip Aker

§


Product: OSAComponents 1.3.0
Distribution Date: 2009-06-20

Copyright © 2002-2009, Philip Aker
All Rights Reserved


§