Satimage Previous | Next
Calling your code from a script
Home Documentation Smile Computing Working with external codes The XCode projects Calling your code from a script  
Once your code made scriptable and compiled, you just have to test it and to use it. How to use your program depends on whether it is a Scripting Addition, or a scriptable application.
Using your new Scripting Addition
Suppose you have produced a Scripting Addition named MyOsax.osax whose dictionary includes the following entry for your MOSolver verb.

MOSolver matrix
     degree integer
     Result : record

When you want to debug your program, run your Scripting Addition as a scriptable application, which will make debugging much easier. To that effect, select DebugOsax as the target for your project, and launch it in debug mode. The rest of the instructions is the same as described in the section about scriptable applications.
The rest of the present section is devoted to the use of the Scripting Addition (or 'osax') in normal conditions, not in the debugging phase.

To make the commands in your osax visible to AppleScript, you must copy the file named MyOsax.osax into the folder /Library/ScriptingAdditions/ or in your user domain in ~/Library/ScriptingAdditions/. If such a ScriptingAdditions folder does not exist, create one with that exact name (which includes no space).
Then you can call your verb from any script, for instance from an AppleScript terminal (a text window) in Smile:


set m to creatematrix "x" ncols 10 nrows 10 as matrix
set n to 3
set x to MOSolver m degree n

Using a scriptable application
Suppose you have made a scriptable application named MyApp.app whose dictionary includes the following entry for your MASolver verb.

MASolver matrix
     degree integer
     Result : record

The command is visible to AppleScript (thus, usable for example in Smile) as soon as the application is running. So if you want to debug your application you may want to launch it first in debug mode from XCode - provided you have compiled with the debug symbols on.
To send the command to your application, use the tell ... end tell wrapper.


set m to creatematrix "x" ncols 10 nrows 10 as matrix
set n to 3
tell application "MyApp" to set x to MASolver m degree n

More information about communicating with a scriptable piece of code, for instance comments about the timeout issue, are available in the following page.
Polling a scriptable application
Version française
Copyright ©2008 Paris, Satimage