![]() |
![]() |
![]() |
TScript |
|
![]() |
Homepage TScript ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
New
version 1.6 of TScript is available: script16.zip
TScript is a Delphi component. It includes an interpreter for a Delphi-pascal like script language. You can use this component for:
The script interpreter consists of three components:
The language of Script uses the basic elements of the delphi language. Begin-End, If-Then-Else, For, While, Repeat-Until are the possible control structures. Operators: Assignment, +, - , *, / div, mod, not. Procedure calls, Constants as usual. In Script you don't need to define the type of a variable. An example: {Calls the procedure print twice} i := 2; while i > 0 do begin i := i - 1; Print (i); end;
print (all) "all" stands for every possible datatype. If the function Print is called, the event "OnEval" is fired. TOnEvalEvent = procedure (Sender : TObject; args : TArgList; var Result : Variant) of Object; The parameter args contains the arguments of the function and res stores the return value (if there is one). A possible implementation of the function Print is: procedure TForm1.fncPrintEval; begin ListBox1.Items.Add (VarToStr (args[0].Eval)); end; "args[0].Eval" returns a variant that hold the value of the first and only argument. All variables and constants use the Delphi datatype variant to store values.
|