Innerfuse Pascal Script
Unit: ifspas.pas

TIFPasScript
TIFPasScript is the script engine, it support most of Object Pascal syntax.

TIfPasScript = class
Protected section:
Variables: PVariableManager;
This list contains all global variables from the current script.

Types: PTypeManager; This list contains all types from the current script.

Procedures: PProcedureManager;
This list contains all the functions (internal and external) of the current script.

Parser: TIfPascalParser;
Contains the parser that is used by the script engine.

CurrProc: PProcedure;
Contains the current function that the script engine is running in.

FAttachedOnes: TIfList;
Contains all attached script engine

FLastException: TIFSError;


Public section
procedure RunError(SE: TIfPasScript; C: TIfPasScriptError);
Makes an error occur.

procedure RunError2(SE: TIfPasScript; C: TIfPasScriptError; Ext: string);
Makes an error occur.

function Getvariable(const Name: string): PIfvariant;
Return variable with name 'Name'.

function Getfunction(s: string): PProcedure;
Return function with name s.

function GetType(const s: string): PTypeRec;
Returns a type with name S.

function Removefunction(D: PProcedure): Boolean;
Remove a function. This does not free the PProcedure record.

function Addvariable(Name, FType: string; constant: Boolean): PIfvariant;
Add a variable to the script engine.

function Addfunction(proc: Pointer; Decl: string; Ext: Pointer): PProcedure;
Add a function to the script engine.

function AddType(const Name, Decl: string): PTypeRec;
Add a type to the script engine.

function AddTypeEx(Name: string): PTypeRec;
Add a type to the script engine, but only create a PTypeRec, user can fill in record.

function AddClass(const Name, Decl: string; RegProc: Pointer): PTypeRec;
Same as AddType, except that all functions are automaticly assigned.

function Callfunction(P: PProcedure; Params: array of variant): variant;
Calls a function

function CallMethod(P: PProcedure; MySelf: PCreatedClass; Params: array of variant): variant;
Calls a method.

function variantToIFvar>iant(const variant; Res: PIfvariant): Boolean;
Copy variant to PIfvariant

function IfvariantTovariant(v: PIfvariant; var res: variant): Boolean;
Copy PIfvariant to variant

function Copyvariant(p: PIfvariant): PIfvariant;
Copy a PIfvariant.

function CreateReal(const E: Extended): PIfvariant;
Create a real number.

function Createstring(const s: string): PIfvariantt;
Create a string.

function CreateInteger(I: Longint): PIfvariant;
Create an integer.

function CreateBool(b: Boolean): PIfvariant;
create a boolean.

function CreatevarType(p: PIfvariant): PIfvariant;
Create a link-to-an-other-variant variant

procedure Cleanup;
Cleanup all classes, variables and resource.s

procedure RunScript;
Run the script engine/

function RunScriptProc(Func: PProcedure; Parameters: PvariableManager): PIfvariant;
Run a function from the script. Returns EParamError with position -1 when number of parameters <> real number of parameters or EParamError with Position (paramno) if the type does not match.

function RunScriptconstructor(FType: PTypeRec; Func: PProcedure; Parameters: PvariableManager): PIfvariant;
Run a script constructor.

function RunInherited(proc: PProcedure; Params: PvariableManager; res: PIfvariant): TIfPasScriptError;
Run an inherited function.

function Setproperty(prop, Data:
PIfvariant): Boolean;
Set a property value.

function Getproperty(prop: PIfvariant): PIfvariant;
Get a property value.

function Attach(ScriptEngine: TIfPasScript): Boolean;
Attach an other script engine to this one.

function Attach2(ScriptEngine: TIfPasScript; FreeOnCleanup: Boolean): Boolean;
Attach an other script engine to this one. If freeOnCleanup is false, the script engine will not be freed.

procedure AddResource(FreeProc: TResourceFree; Data: Pointer);
Add a rsource to the resource list.

procedure RemoveResource(Data: Pointer);
Remove a resource from the resource list.

function IsValidResource(FreeProc: TResourceFree; Data: Pointer): Boolean;
Check if it's a valid resource.

function FindResource(FreeProc: TResourceFree): Pointer;
Search for resource with FreeProc (freeProc)

procedure SetText(const Data: string);
Set the current text.

procedure SetPData(const Data: string);
Load the text as pcode data.

function GetPData(var Data: string): Boolean;
Returns the current pcode data.

constructor Create(id: Pointer);
Create an instance of the script engine.

destructor Destroy; Override;
Destroy an instance of the script engine.

property ModuleName: string read FModuleName write FModuleName;
Return or set the name of this module. It is equal to the program or unit parameter.

property IsUnit: Boolean read FIsUnit;
This is true when the current file is a unit.

property OnRunLine: TOnRunLine Read FOnRunLine Write FOnRunLine;
This event is called every time that a line has been runned.

property OnUses: TOnUses Read FOnUses Write FOnUses;
This event is called when a script is assigned with 'SYSTEM' parameter and for each uses.

property OnExternal: TOnExternal read FOnExternal write FOnExternal;
This event is called when a external function is called.

property ErrorCode: TIfPasScriptError read GetErrorCode;
This contains current error code

property ErrorPos: Longint Read GetErrorPos;
This contains the position of the error that has occured.

property Errorstring: string Read GetErrorString;
This contains the parameter for current error.

property ErrorModule: string read GetErrorModule;
This contains the module the error has happend in.

property MaxBeginNesting: Longint read FMaxBeginNesting write FMaxBeginNesting;
This is the maximum number of nestings.

property MaxArrayLength: Longint read FMaxArrayLength write FMaxArrayLength;
This is the maximum length on an array (not yet used in current version).


Copyright (c) 2001 by Carlo Kok
last update: 24-11-01