TDelphiWebScript Component
constructor
Create (AOwner : TComponent);
Creates a new TDelphiWebScript component.
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
Send (s : string);
procedure SendLn (s : string);
Add string s to the outputstring.
SendLn adds also a trailing newline.
procedure
SendFile(filename: string);
Writes the content of file "filename"
to the output string.
function
NewObj (obj : TdwsObject) : Integer;
Stores a new TdwsObject in the object list
and returns a handle.
procedure
FreeObj (h : Integer);
Removes the TdwsObject with handle h from
the object list.
function
GetObj (h : Integer) : TdwsObject;
Returns the TdwsObject with handle h.
function
AddFunction (fnc : TFunction) : TFunction;
Adds a function object to the list of the known functions
function
DeleteFunction (fnc : TFunction) : boolean;
Removes a function form the list of the known functions
function
GetFunction (nam : string) : TFunction;
Returns the function object with name nam from
the list of known functions
function
GetFunctionIndex (x : Integer) : TFunction;
Returns the function with index x
from the list of the known functions.
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;
See "External Variables" for further information
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
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 position in the memo holding
your scriptcode.
Events
event
OnVarChange (scr : TDelphiWebScript; item : TDataItem;
oldval, newval : Variant);
This event is fired if
variable is changed during the execution of the script.
event OnDebug
(scr : TDelphiWebScript; expr : TExpr);
This event is fired if a
function is called during the execution of the script.
Using this event it's possible to debug the script.
Properties
property Result :
String;
Returns
the output of the script. To create output in script code
use functions send and sendln.
property Msgs:
TMsgs;
If Compile() or Execute() return False the
property Msgs contains the error messages. Msgs[x]
returns one of the Msgs.Count TMsg objects.
property Mode
: TTokenizerMode;
The property mode has three diffrent
settings: tmNormal support for scripts embeded in HTML
code is switched off. tmHtmlAsp: use <% %> and <%=
%> to embed scripts in HTML code. tmHtmlComment: use
<!-- /--> and <!--= /--> to embed your
scripts.
property
IncludePath : string;
Default path for Include files. The
statement "{$I <includefile>}" includes
the file IncludePath + includefile into your script.
property
PluginPath: string;
Default path for plugin files. The compiler
switch {$U 'file'} loads a the plugin file "PluginPath
+ file".
property
Plugins: TStrings;
A list of plugin files (relative to
PluginPath) that are loaded when the TDelphiWebScript
object is created.
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
messages are shown in messageboxes.
property Text
: string;
Assign your scriptcode to this property
before calling compile or execute.
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.
property
Timeout : Integer;
If the property timeout has a value
diffrent to zero, the execution of the script program
terminates when timeout seconds have expired
raising a runtime error. This is useful to avoid never
ending script programs if blocking is set to true.
property
Funcs[x : Integer] : TFunction;
A list of known functions.
property Vars[x
: Integer] : TDataItem;
proprety Globals[x : Integer] : TDataItem;
See "External Variables" for further information
|