Technical Information
=====================

If you assign a string to the TScript's "Text" property and then call
the "Compile" method the following things will happen:

Tokenizer (Scanner)
-------------------

The string containing the script program code is broken up into tokens.
A script program like "a := 2;" would result in this tokenlist:
["A"] [SPACE] [":="] [SPACE] [2] [";"]

Parser
------
The parser turns the token list into a tree of TExpr objects. Every node in
this tree is a function represented by a TFuncExpr object. The children of a node
are the arguments of the function. Control structures like "while do end",
"for do end" and "if then else" are mapped to functions. E. g. "if 
then else" is beeing mapped to a function "IF" that has three arguments.
The first argument returns a boolean value. If it's true the second argument is
evaluated otherwise the third. 

The tree generated by the parser consists of three subclasses of TExpr:

TFuncExpr
- Encapsulates a function. 
- Method "Eval" evaluates the function using its arguments and returns
the result value if there is one.

TVarExpr
- Encapsulates a variable used in the script
- Method "Eval" returns the value of the variable
- Method "SetValue" sets a new value

TArrayExpr
- Encapsulates an element of an array
- Method "Eval" returns the value of the array-element
- Method "SetValue" sets a new value for the array-element

TConstExpr
- Represents a constant value or a constant declared in the "const" section
- Method "Eval" returns the constant value 

Execution
---------
If you call the "Execute" method of the TScript component, the "Eval" method
of the base TFuncExpr object is called. This object evaluates its arguments 
exactly once. If an argument is a function, this function evaluates its 
arguments and so on...

Variables
---------
For every variable found in the script code the parser creates a TVariable 
object. After compilation all TVariable objects contain the value varClear.
(see "Variants" in the online help of Delphi) The first assignment fixes 
the type of the TVariable object. Every other assignments have to be of the 
same type.

a := 'Hallo';

This statement fixes the variable "a" to the type "string". An further 
assignment like the following would result in a run-time-error:

a := 2;

You can create and set variables after compilation and before execution
using the TScript.SetVar and TScript.GetVar methods.

Arrays
------
Arrays are stored as arrays of Variants. They are created using the command
VarArrayCreate (see Delphi help). To create an array in code use this
lines

var
  v : Variant;
begin
  v := VarArrayCreate ([0, 2], varVariant);
  Script1.SetVar ('x', v);
end;


Constants
---------
Constants are read-only variables set by the compiler.


