TScript

TScript Usage

Homepage
TScript
TScript Usage
 

TScript Component

constructor Create (AOwner : TComponent);
Creates a new TScript component.

class function LineOfPos (memo : TMemo; pos : Integer) : Integer;
class function ColOfPos (memo : TMemo; pos : Integer) : Integer;
Class functions calculating the line number and the column number of a TScript-token-position in a memo.

procedure SetVar (nam : string; val : Variant);
function GetVar (nam : string) : TDataItem;
function GetVarIndex (i : Integer) : TDataItem;
procedure SetGlobal (nam : string; val : Variant);
function GetGlobal (nam : string) : TDataItem;
procedure SetGlobalConst (nam : string; val : Variant);
function GetGlobalIndex (i : Integer) : TDataItem;
procedure DeleteGlobal (nam : string);
procedure DeleteGlobals;
property GlobalCount : Integer;
property ItemCount : Integer;
See "
External Variables" for further information

function Compile : boolean;
Compiles the script in TScript.Text. Returns false if an error occurrs during the compiling process.

function Execute : boolean;
Executes the script previously compiled. If the script is not yet compiled the method TScript.Compile is called first. If the execution of the script was successful "Execute" returns true. If another script was running or an error occurred it returns false.

procedure Stop;
Stops the execution of the currently running script. An EStop exception occurrs. Works only in non blocking mode

procedure ShowTree (tv : TTreeView);
TScript.Compile generates a tree of TExpr objects. This method visualizes this tree in a TreeView component. The nodes in the TTreeView component

Properties

property Result : Variant;
Returns the value of the script variable result. If you don't use the variable result in your script this property returns an empty variant.

property Compiled : boolean;
Returns true if the script in TScript.Text is compiled.

property Executing : Boolean;
Returns true if actually a script is running.

property Exceptions : Boolean;
If Exceptions is true compiler- and runtime-errors generate an exception (EScriptError). Otherwise the error message is shown in a messagebox.

property Text : string;
Holds the script code.

property Functions : TFuncs;
The TFuncs object you need to assign.

property Blocking : Boolean;
If blocking is true the execution of a script blocks your application. You have to care about updating the user interface yourself. Blocking mode speeds up the execution of a script especially if you use VCL calls in you OnEval methods. If non-blocking mode is enabled the script can be stopped by TScript.stop. If the application is terminated the script stops, too.