Units | Class Hierarchy | Classes, Interfaces and Objects | Types | Variables | Constants | Functions and Procedures | Identifiers

# Class TIFPSExec

## Unit

ifps3

## Declaration

`type TIFPSExec = class(TObject)`

## Description

TIFPSExec is the core of the script engine executer

## Fields

| Name | Description
--- | --- | ---
| `ExEx` | The error code
| `ExParam` | The optional parameter for the error
| `ExPos` | The position of the last error
| `ExProc` | The proc where the last error occured
| `FCurrentPosition` | The current position in the current proc
| `FCurrProc` | The current proc
| `FCurrStackBase` | Current stack base
| `FExceptionStack` | The exception stack
| `FExportedVars` | The list of exported variables
| `FGlobalVars` | FGlobalVars contains the global variables of the current script
| `FMainProc` | The main proc no or -1 (no main proc)
| `FOnRunLine` | FOnRunLine event
| `FProcs` | FProcs contains all script procedures
| `FRegProcs` | List of all registered external functions
| `FResources` | The list of resources
| `FRPSupFuncs` |
| `FSpecialProcList` | List of SpecialProcs; See TIFPSExec.AddSpecialProc
| `FStack` | The current stack
| `FStatus` | The current status of the script engine
| `FTypes` | FTypes contains all types used by the script
| `MM` | MM is the memory manager used internally. It's needed to create and destroy variants

## Methods

### Overview

| `constructor Create;`
| `destructor Destroy; Override;`
| `class function About: string;`
| `procedure AddResource(Proc, P: Pointer);`
| `procedure AddSpecialProcImport(const FName: string; P: TIFPSOnSpecialProcImport; Tag: Pointer);`
| `procedure Cleanup; Virtual;`
| `procedure Clear; Virtual;`
| `procedure ClearFunctionList;`
| `procedure ClearspecialProcImports;`
| `procedure CMD_Err(EC: TIFError);`
| `procedure CMD_Err2(EC: TIFError; const Param: string);`
| `function CreateFloatVariant(FType: PIFTypeRec; Value: Extended): PIfVariant;`
| `function CreateIntegerVariant(FType: PIFTypeRec; Value: Longint): PIfVariant;`
| `function CreateStringVariant(FType: PIFTypeRec; const Value: string): PIfVariant;`
| `procedure DeleteResource(P: Pointer);`
| `procedure ExceptionProc(proc, Position: Cardinal; Ex: TIFError; const s: string); Virtual;`
| `function FindProcResource(Proc: Pointer): Pointer;`
| `function FindProcResource2(Proc: Pointer; var StartAt: Longint): Pointer;`
| `function FindType(StartAt: Cardinal; BaseType: TIFPSBaseType; var l: Cardinal): PIFTypeRec;`
| `function FindType2(BaseType: TIFPSBaseType): PIFTypeRec;`
| `function GetProc(const Name: string): Cardinal;`
| `function GetProcNo(C: Cardinal): PIFProcRec;`
| `function GetType(const Name: string): Cardinal;`
| `function GetTypeNo(l: Cardinal): PIFTypeRec;`
| `function GetVar(const Name: string): Cardinal;`
| `function GetVar2(const Name: string): PIFVariant;`
| `function GetVarC(const Name: string): Cardinal;`
| `function GetVarC2(const Name: string): PIFVariant;`
| `function GetVarNo(C: Cardinal): PIFVariant;`
| `function ImportProc(const Name: ShortString; var proc: TIFProcRec): Boolean; Virtual;`
| `function InnerfuseCall(_Self, Address: Pointer; CallingConv: TIFPSCallingConvention; Params: TIfList; res: PIfVariant): Boolean;`
| `function IsValidResource(Proc, P: Pointer): Boolean;`
| `function LoadData(const s: string): Boolean; virtual;`
| `procedure Pause; Virtual;`
| `procedure RegisterDelphiFunction(ProcPtr: Pointer; const Name: string; CC: TIFPSCallingConvention);`
| `procedure RegisterDelphiMethod(Slf, ProcPtr: Pointer; const Name: string; CC: TIFPSCallingConvention);`
| `function RegisterFunctionName(const Name: ShortString; ProcPtr: TIFProc; Ext1, Ext2: Pointer): PProcRec;`
| `procedure RegisterRProcSupFuncs(P: PResourcePtrSupportFuncs);`
| `procedure RunLine; virtual;`
| `function RunProc(Params: TIfList; ProcNo: Cardinal): Boolean;`
| `function RunScript: Boolean;`
| `procedure Stop; Virtual;`

### Description

| `constructor Create;`

Create an instance of the executer

| `destructor Destroy; Override;`

Destroy this instance of the executer

| `class function About: string;`

This function will return about information

| `procedure AddResource(Proc, P: Pointer);`

Add a resource

| `procedure AddSpecialProcImport(const FName: string; P: TIFPSOnSpecialProcImport; Tag: Pointer);`

Add a special proc import; this is used for the dll and class library

| `procedure Cleanup; Virtual;`

Reset all variables in the script to zero

| `procedure Clear; Virtual;`

Clear the currently loaded script

| `procedure ClearFunctionList;`

Clear the function list

| `procedure ClearspecialProcImports;`

Clear the list of special proc imports

| `procedure CMD_Err(EC: TIFError);`

Call CMD_Err to cause an error and stop the script

| `procedure CMD_Err2(EC: TIFError; const Param: string);`

Call CMD_Err2 to cause an error and stop the script

| `function CreateFloatVariant(FType: PIFTypeRec; Value: Extended): PIfVariant;`

Create a float variant

| `function CreateIntegerVariant(FType: PIFTypeRec; Value: Longint): PIfVariant;`

Create an integer variant

| `function CreateStringVariant(FType: PIFTypeRec; const Value: string): PIfVariant;`

create a string variant

| `procedure DeleteResource(P: Pointer);`

Delete a resource

| `procedure ExceptionProc(proc, Position: Cardinal; Ex: TIFError; const s: string); Virtual;`

ExceptionProc is called when an error occurs

| `function FindProcResource(Proc: Pointer): Pointer;`

Find a resource

| `function FindProcResource2(Proc: Pointer; var StartAt: Longint): Pointer;`

Find a resource

| `function FindType(StartAt: Cardinal; BaseType: TIFPSBaseType; var l: Cardinal): PIFTypeRec;`

Search for a type (l is the starting position)

| `function FindType2(BaseType: TIFPSBaseType): PIFTypeRec;`

Search for a type

| `function GetProc(const Name: string): Cardinal;`

Get function that has been compiled with a name

| `function GetProcNo(C: Cardinal): PIFProcRec;`

Get Proc no (C)

| `function GetType(const Name: string): Cardinal;`

Get Type that has been compiled with a name

| `function GetTypeNo(l: Cardinal): PIFTypeRec;`

Return type no L

| `function GetVar(const Name: string): Cardinal;`

Get variable that has been compiled with a name

| `function GetVar2(const Name: string): PIFVariant;`

Get variable compiled with a name as a variant

| `function GetVarC(const Name: string): Cardinal;`

Get variable no (C)

| `function GetVarC2(const Name: string): PIFVariant;`

Get variable compiled with a name as a variant (Case insensitive, ie name is first uppercase)

| `function GetVarNo(C: Cardinal): PIFVariant;`

Get variable no (C), (Case insensitive, ie name is first uppercase)

| `function ImportProc(const Name: ShortString; var proc: TIFProcRec): Boolean; Virtual;`

ImportProc is called when the script needs to import an external function

| `function InnerfuseCall(_Self, Address: Pointer; CallingConv: TIFPSCallingConvention; Params: TIfList; res: PIfVariant): Boolean;`

Call a method

| `function IsValidResource(Proc, P: Pointer): Boolean;`

Check if P is a valid resource for Proc

| `function LoadData(const s: string): Boolean; virtual;`

Load data into the script engine

| `procedure Pause; Virtual;`

Pause the script engine

| `procedure RegisterDelphiFunction(ProcPtr: Pointer; const Name: string; CC: TIFPSCallingConvention);`

| `procedure RegisterDelphiMethod(Slf, ProcPtr: Pointer; const Name: string; CC: TIFPSCallingConvention);`

Register a delphi function ProcPtr is a pointer to the proc to be called; Name is the name of that proc (uppercased). CC is the calling convention.

| `function RegisterFunctionName(const Name: ShortString; ProcPtr: TIFProc; Ext1, Ext2: Pointer): PProcRec;`

Register a function by name

| `procedure RegisterRProcSupFuncs(P: PResourcePtrSupportFuncs);`

| `procedure RunLine; virtual;`

RunLine function

| `function RunProc(Params: TIfList; ProcNo: Cardinal): Boolean;`

Use RunProc to call a script function. The Params will not be freed after the call

| `function RunScript: Boolean;`

Run the current script

| `procedure Stop; Virtual;`

Stop the script engine

## Properties

### Overview

| `property CallCleanup: Boolean;`
| `property ExceptionCode: TIFError;`
| `property ExceptionPos: Cardinal;`
| `property ExceptionProcNo: Cardinal;`
| `property ExceptionString: string;`
| `property Id: Pointer;`
| `property MemoryManager: Pointer;`
| `property OnRunLine: TIFPSOnLineEvent;`
| `property Status: TIFStatus;`

### Description

| `property CallCleanup: Boolean;`

Set CallCleanup to false when you don't want the script engine to cleanup all variables after RunScript

| `property ExceptionCode: TIFError;`

Contains the last error code

| `property ExceptionPos: Cardinal;`

Contains the last error position

| `property ExceptionProcNo: Cardinal;`

Contains the last error proc

| `property ExceptionString: string;`

Contains the last error string

| `property Id: Pointer;`

Optional tag of the script engine

| `property MemoryManager: Pointer;`

The MemoryManager used when calling CreateVariant/DestroyVariant

| `property OnRunLine: TIFPSOnLineEvent;`

The OnRunLine event is called after each executed script line

| `property Status: TIFStatus;`

Status contains the current status of the scriptengine