Futurebasic/Language/Reference/usr applescriptloadandrun


Revised June, 2003 (Release 8)

Description - This routine loads and executes the AppleScript script specified by resID% and located in the file specified by fSpec. If the routine fails to launch the script errorFlag is set to a non-zero value. If the script returns a result, you can get a handle pointing to the data using the USR APPLESCRIPTGETRESULT function. Note that the script might also return an error in the AppleScript buffer, therefore you should always empty the buffer after a script has been executed getting the result with USR APPLESCRIPTGETRESULT then disposing of the handle returned if any. fSpec is an FSSpec record specifying an existing file. If you pass _nil for the fSpec parameter, the script will be retrieved from the resource fork of the running application.

Note: Usually, resID% is set to 128 which is the default resource ID for Apple's compiled scripts. However, if you pass 0 for this parameter, the routine will assume an ID of 128, thus USR APPLESCRIPLOADANDRUN(0,0) is functionally equivalent to USR APPLESCRIPLOADANDRUN(appSpec,128). In order for the script to function properly, your program must have entered its main event loop before it attempts to run the script.