home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / cddk9605.zip / HEADERS.ARJ / SCRIPTS.INT < prev    next >
Text File  |  1996-05-17  |  5KB  |  169 lines

  1.  
  2. { ───────────────────────────────────────────────────────────────────────── }
  3. {  Name        : SCRIPTS.PAS                                                }
  4. {  Description : Script Interpreter                                         }
  5. { ───────────────────────────────────────────────────────────────────────── }
  6.  
  7. UNIT Scripts;
  8.  
  9. {$B-} { . . . . . . . . . . . . . . . . . . . . Shortcut boolean evaluation }
  10. {$F+} { . . . . . . . . . . . . . . . . . . . .  Force far calls for safety }
  11. {$I-} { . . . . . . . . . . . . . . . . . . . Disable input/output checking }
  12. {$O+} { . . . . . . . . . . . . . . . . . . Allow this unit to be overlayed }
  13. {$Q-} { . . . . . . . . . . . . . .  Do not generate overflow-checking code }
  14. {$R-} { . . . . . . . . . . . . . . . . Do not generate range-checking code }
  15. {$S-} { . . . . . . . . . . . . . . . . Do not generate stack-checking code }
  16. {$X+} { . . . . . . . . . . . Extended syntax for pChars and function calls }
  17.  
  18. INTERFACE
  19.  
  20. USES
  21.   Objects;
  22.  
  23. CONST
  24.  
  25.   { Identifier types }
  26.  
  27.   _Unknown  = $00;     { . . . .  Unknown type or reserved identifier name }
  28.   _Function = $01;     { . . . . . . . . . . . Programmer-defined function }
  29.   _Label    = $02;     { . . . . . . . . . . . . . Reserved for future use }
  30.   _Variable = $03;     { . . . . . . . . . . . Programmer-defined variable }
  31.   _Status   = $04;     { . . . . . . . . . . . . Reserved for status lines }
  32.   _Menu     = $05;     { . . . . . . . . . . . . . . .  Reserved for menus }
  33.  
  34.  
  35. TYPE
  36.  
  37.   tID = OBJECT(tObject)
  38.  
  39.     NameStr : pChar;   { . . . . . . . . . . . . The name of the identifier }
  40.     NameCRC : LongInt; { . . . . . . . . . . . . The 32-bit CRC of its name }
  41.     Family  : Word;    { . . . The family of the identifier (i.e. variable) }
  42.  
  43.     CONSTRUCTOR Init(p:pChar; k:Word);
  44.     DESTRUCTOR  Done; VIRTUAL;
  45.     END;
  46.  
  47.   pID = ^tID;
  48.  
  49.   tParams = OBJECT(tCollection)
  50.     PROCEDURE FreeItem(Item:Pointer); VIRTUAL;
  51.     PROCEDURE InsertString(p:pChar); VIRTUAL;
  52.     END;
  53.  
  54.   pParams = ^tParams;
  55.  
  56.   tFunction = OBJECT(tID)
  57.     Handler : PROCEDURE(p:pParams);
  58.     Params  : Byte;
  59.     CONSTRUCTOR Init(p:pChar; HandlerPtr:Pointer; Count:Byte);
  60.     END;
  61.  
  62.   pFunction = ^tFunction;
  63.  
  64.   tVariable = OBJECT(tID)
  65.     Address  : Pointer;
  66.     ReadOnly : Boolean;
  67.     CONSTRUCTOR Init(p:pChar; Addr:Pointer);
  68.     PROCEDURE Assign(p:pChar); VIRTUAL;
  69.     FUNCTION  Obtain:STRING; VIRTUAL;
  70.     END;
  71.  
  72.   pVariable = ^tVariable;
  73.  
  74.  
  75. CONST
  76.   IDs       : pCollection = NIL;
  77.   ScriptDir : pChar       = NIL;
  78.  
  79.  
  80. PROCEDURE DeleteID(p:pChar);
  81.   {
  82.   PURPOSE  : Deletes the identifier.
  83.  
  84.   NOTES    : The name of the identifier is not case-sensitive.
  85.   }
  86.  
  87.  
  88. FUNCTION Execute(Source:pChar):Word;
  89.   {
  90.   PURPOSE  : Interpreters the string of commands.
  91.  
  92.   SEE ALSO : Script
  93.   }
  94.  
  95.  
  96. FUNCTION Let(Variable,Equal:pChar):Boolean;
  97.   {
  98.   PURPOSE  : Assigns a value to the specified variable.
  99.  
  100.   RETURNS  : TRUE if the operation was successful, FALSE if not.  The
  101.              operation will fail if the specified variable is read-only
  102.              or does not exist.
  103.   }
  104.  
  105.  
  106. PROCEDURE MakeReadOnly(Variable:pChar);
  107.   {
  108.   PURPOSE  : Makes a variable read-only.  A read-only variable cannot be
  109.              modified by the sysop.
  110.  
  111.   EXAMPLE  : PROCEDURE Protect_Software;
  112.                BEGIN
  113.                MakeReadOnly('Author');
  114.                MakeReadOnly('Copyright');
  115.                MakeReadOnly('Version');
  116.                END;
  117.   }
  118.  
  119.  
  120. PROCEDURE Parse(p:pChar; VAR Index,Length,Next:Word);
  121.   {
  122.   PURPOSE  : Parses a token in a string.
  123.  
  124.   PARAMS   : p        The string to parse.
  125.              Index    The starting position of the parser.  Upon return
  126.                       this variable contains the starting position of
  127.                       the next token.
  128.              Length   The length of the token.
  129.              Next     The suggested starting position of the next Parse call.
  130.   }
  131.  
  132.  
  133. PROCEDURE RegisterFunction(Name:pChar; Addr:Pointer; Count:Byte);
  134.   {
  135.   PURPOSE  : Registers a function with the script interpreter.
  136.  
  137.   PARAMS   : Name     The name of the function (not case-sensitive).
  138.              Addr     The address of the function handler.
  139.              Count    The number of parameters to send to the handler.
  140.  
  141.   NOTES    : A function handler is declared as follows:
  142.  
  143.              PROCEDURE <NAME>(<POINTER>:pParams);
  144.  
  145.              Where <NAME> is the name of the handler, and <POINTER>
  146.              is the name of a tParams pointer.  The handler must use
  147.              any other parameters; this will cause memory stack problems.
  148.   }
  149.  
  150.  
  151. FUNCTION Script(p:pChar):Word;
  152.   {
  153.   PURPOSE  : Executes a script file.
  154.  
  155.   NOTES    : The ScriptDir string is used instead of any specified path,
  156.              if ScriptDir is not NIL.
  157.  
  158.   SEE ALSO : Execute
  159.   }
  160.  
  161.  
  162. FUNCTION SearchFor(p:pChar):pID;
  163.   {
  164.   PURPOSE  : Scans the list of identifiers stored in IDs and returns a
  165.              pointer if the specified name exists.
  166.   }
  167.  
  168.  
  169.