home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 12 - 1996 / 12.02 Feb 96 / Adding Scripts to Menus / Scripts MenuCode / UScripting.h < prev   
Encoding:
Text File  |  1995-03-30  |  1.6 KB  |  53 lines  |  [TEXT/MMCC]

  1. // ===========================================================================
  2. // UScripting.h -- support class for scripting
  3. // ===========================================================================
  4. // © 1995 James Kaput, Jeremy Roschelle SimCalc Project
  5.  
  6. #pragma once
  7.  
  8. #include <osa.h>
  9.  
  10. class UScripting{
  11.     public:
  12.     
  13.          // call this once at app launch time
  14.         static void Initialize();                 
  15.         
  16.         // get/set default component
  17.         static ComponentInstance GetComponent()
  18.                                     {return sComponent;};
  19.         static void              SetComponent(ComponentInstance inComponent)
  20.                                     {sComponent = inComponent;};
  21.  
  22.         // returns a handle to the 'scpt' and 'TEXT' resource
  23.         // you should pass in pointers to unallocated handles
  24.         // this routine will set the handles to nil if it can't find or allocate them
  25.         static OSErr ParseScriptFile(FSSpec &inFile, Handle &outScript, Handle &outText);
  26.         
  27.         // will make a ScriptEditor file
  28.         static OSErr CreateScriptFile(FSSpec &inFile,Handle inScript, Handle inText);
  29.  
  30.         // load, execute and dispose a script
  31.         static OSErr LoadScript(Handle inScript, OSAID &outScriptID);
  32.         static OSErr LoadScript(AEDesc &inScriptDesc, OSAID &outScriptID);
  33.         static OSErr ExecuteScript(OSAID inScriptID);
  34.         static OSErr DisposeScript(OSAID inScriptID);
  35.  
  36.     private:
  37.         static ComponentInstance    sComponent;
  38.  
  39.  
  40. };
  41.  
  42. // note: the purpose of this class is to execute a script once
  43. // at the end of the processing of the current event
  44. class URun1Script : public LPeriodical 
  45. {
  46.     public:
  47.         URun1Script(OSAID    inScriptID);
  48.         virtual    void    SpendTime(const EventRecord &inMacEvent);
  49.         
  50.     protected:
  51.         OSAID    mScriptID;
  52. };
  53.