Futurebasic/Language/Reference/usr applescriptrun

USR APPLESCRIPTRUN( errorMessage$ )

Revised June, 2003 (Release 8)

Description - This function compiles and executes an AppleScript script that has been previously stored in FB's AppleScript internal buffer with the ROUTE statement. The result returned by the routine is in the form of a flag that indicates whether the script was successfully compiled (_noErr) or if the operation has failed (non-zero value). The errorMessage$ parameter will contain the result of the script (if any) or a human friendly error message from AppleScript. The errorMessage$ variable is set up to contain up to 255 characters, consequently if the result of the script is larger than the maximum allowed, you will not get the full data returned by the script. In such case you may wish to use the USR APPLESCRIPTGETRESULT routine to get a handle to the entire result. In any case you must call that function to empty the AppleScript buffer and dispose of the possible handle returned. Example:

The following example will return the file access path of the running application:

INCLUDE "Subs AppleScript.Incl"

DIM err

DIM reply$ or DIM reply AS STR255 ''' NEED LINK!!! ''' ROUTE _toAppleScript

PRINT "path to me as string"

ROUTE _toScreen err = USR APPLESCRIPTRUN

IF err = _noErr THEN PRINT reply$ resultHandle = USR APPLESCRIPTGETRESULT

IF resultHandle THEN CALL DisposeHandle( resultHandle )

Program output: Macintosh HD:AppleScriptRun folder:FB_Temp Note: In order for the script to function properly, your program must have entered its main event loop before it attempts to run the script.

See Also USR APPLESCRIPTGETRESULT; USR APPLESCRIPTSTORE