TIfPasScript

Unit: IFSPas.Pas
TIFPasScript is the pascal script engine.

TIfPasScript = class


procedure RunError(SE: TIfPasScript; C: TIfPasScriptError);
Cause an error to occur.

procedure RunError2(SE: TIfPasScript; C: TIfPasScriptError; Ext: string);
Cause an error to occur. Usefull for causing ECustomErrors with parameters within RegisteredProcs.

function CreateReal(FTypes: PTypeManager; const e: Extended): PIfVariant;
Create a real number. Use ScriptEngine.Types as FTypes.

function CreateString(FTypes: PTypeManager; const s: string): PIfVariant;
Create a string. Use ScriptEngine.Types as FTypes.

function CreateInteger(FTypes: PTypeManager; i: LongInt): PIfVariant;
Create an integer number. Use ScriptEngine.Types as FTypes.

function CreateBool(FTypes: PTypeManager; b: Boolean): PIfVariant;
Create a boolean. Use ScriptEngine.Types as FTypes.

function CreateVarType(p: PIfVariant): PIfVariant;
Create a link to an other variant. When freeing this, it does not free the variable it links to.

function GetVariable(const Name: string): PIfVariant;
Returns a script variable.

function GetFunction(s: string): PProcedure;
Returns a script function.

function GetType(const s: string): PTypeRec;
Returns a type from within the scripting engine.

function AddVariable(Name, FType: string; Constant: Boolean): PIfVariant;
Adds a variable to the script engine. It returns the PIFVariant containing the variable. You can use that to set the contents of the variable.

function AddTypeEx(Name: string): PTypeRec;
Use this function to add a new type to the script engine. It's used to add special kind of variables.

function AddType(name, decl: string): Boolean;
Use this function to add new types to the script engine (only call this in OnUses event).

function AddClass(const Name, Decl: string; RegProc: Pointer): PTypeRec;
Add a class to the script engine. See TRegisteredProc for an details about regproc.

function AddFunction(Proc: Pointer; Ext: Pointer; Decl: String): Boolean;
Add an external function to the script engine (only call this in OnUses event). Decl is the standard pascal function header. Proc is a pointer to a TRegisteredProc like procedure.

function RemoveFunction(D: PProcedure): Boolean;
Removes a function from the function list. It does not call Dispose on D.

procedure RunScript;
Run the script.

function CallFunction(P: PProcedure; Params: Array of Variant): Variant;
Call a function. Use this for a quick call, as this sets up the PVariableManager.

function CallMethod(P: PProcedure; MySelf: PCreatedClass; Params: Array of Variant): Variant;
Call a method. Use this for a quick call, as this sets up the PVariableManager.

function RunScriptProc(Func: PProcedure; Parameters: PVariableManager): PIfVariant;
Run a function in the script engine. Use GetFunction to get the Func pointer.

function RunScriptConstructor(FType: PTypeRec; Func: PProcedure; Parameters: PVariableManager): PIfVariant;
Run a class constructor.

function RunInherited(Proc: PProcedure; Params: PVariableManager; res: PIfVariant): TIfPasScriptError;
Run an inherited instance of a class.

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

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

function IsValidResource(FreeProc: TResourceFree; Data: Pointer): Boolean;
Check if it is really your resource (FreeProc should be the same as in AddResource).

procedure SetText(Data: string);
Set the pascal code inside.

procedure SetPData(const Data: string);
Set the pascal code inside the script engine with PData.

function GetPData(var Data: string): Boolean;
Return the Data inside the script engine as PData.

procedure Cleanup;
Cleans up classes and resource after the script engine has runned. After calling this everything is zero again. Automaticly called in SetText.

function Attach(ScriptEngine: TIfPasScript): Boolean;
Attach an other script engine to this one. The script engine will automaticly be freed. The current script engine will be able to use variables, types and functions from the other one.

function CopyVariant(p: PIfVariant): PIfVariant;
Copy a variant into a new variant.

function SetProperty(prop, Data: PIfVariant): Boolean;
Set the contents of a property.

function GetProperty(prop: PIfVariant): PIfVariant;
Returns the contents of a property or NIL if an error occurs.

function VariantToIFVariant(const v: Variant; Res: PIfVariant): Boolean;
Convert a Delphi variant to a PIFVariant.

function IfVariantToVariant(v: PIfVariant; Var res: Variant): Boolean;
Convert a PIFVariant to a Delphi variant.

constructor Create(ID: Pointer);
Create the script engine. ID is only used as an pointer that you can use freely.

destructor Destroy; override;
Destroy the script engine.

property OnRunLine: TOnRunLine;
OnRunLine event.

property OnUses: TOnUses;
OnUses event.

property ErrorCode: TIfsError//readonly
The error that has happened in the script.

property ErrorPos: LongInt; //readonly
The position of the error that has occured.
property ModuleName: string
The module name. Is set to the Program/Unit parameter. Default is 'main'.

property IsUnit: Boolean // readonly
Return if the file is a unit.
property ErrorString: string // readonly
Return the parameter to the error. Is used for ErrorToString function.

property ErrorModule: string // readonly
Returns the module the error has occured in.

property MaxBeginNesting: Longint
The Maximum allowed Begin nesting. Use it to make the script engine a little bit safer.

property MaxArrayLength: Longint
The Maximum length of an array.

end;