Usr AppleScriptStore(fSpec, resID%, scriptName$)
Revised August, 2002 (Release 7)
Description - This routine saves a compiled script into the resource fork of the file specified by fSpec with a resource ID and a resource name specified respectively by resID% and scriptName$. Once you have filled the AppleScript internal buffer with the Route and Print statements, you may wish to store the script permanently in compiled format for later use. The resulting script file can be run with the Usr AppleScriptLoadAndRun routine as well as with any application that can run AppleScript scripts such as Apple Script Editor. fSpec is an FSSpec record that specifies a file. If the file doesnÕt exist, it is created. If you pass _nil for the fSpec parameter, the resulting compiled script will be stored in the resource fork of the running application. resID% is usually set to 128 (the default resource ID for AppleÕs compiled scripts), and if you pass zero for this parameter the routine will assume an ID of 128. The routine will override any existing script having the same ID in the file specified.
For example, Usr AppleScriptStore would store or replace in the resource fork of the running application a script with resource ID 128 whose resource name would be ÒMy ScriptÓ. You can pass a null string for the scriptName$ parameter.
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. The AppleScript routines are made available to your program with the following Include statement:
Include "Subs AppleScript.Incl"
See Also: Usr AppleScriptGetResult; USR APPLESCRIPLOADANDRUN