TatCustomScripter Class
Base class for all TMS Scripter components, providing script compilation, execution, and Delphi interop registration.
Remarks
TatCustomScripter holds a collection of scripts in the Scripts property. Scripts can be added, compiled individually, and executed. For scripts to access Delphi variables, classes, methods, and properties, that information must be registered with the scripter using methods such as DefineMethod, DefineClass, and others. All registered class information is stored in the Classes property collection.
Syntax
Unit: atScript
TatCustomScripter = class(TComponent);
Constructors
| Name | Description |
|---|---|
| Create | Creates a new scripter component instance and initializes its internal state. |
Methods
| Name | Description |
|---|---|
| AddComponent | Registers the component specified by AComp to be accessible from all scripts. The component will be accessible by its name. Published properties of component will also be automatically available for reading/writing. |
| AddComponents | Registers all components owned by AComp to be accessible from all scripts by their names. |
| AddConstant | Registers a constant value to be accessible from all scripts by the given name. |
| AddDataModule | Registers the data module instance ADataModule to be accessible from all scripts, exposing its owned components as properties. |
| AddDelphiClass | Deprecated. Use DefineClass instead. |
| AddEnumeration | Registers an enumerated type so that all its values are accessible by name from all scripts. |
| AddForm | Registers the form instance AForm to be accessible from all scripts, exposing its owned components as properties. |
| AddFunction | Deprecated. Use DefineMethod instead. |
| AddLibrary | Instantiates and registers the library class ALibraryClass in the scripter. |
| AddLibraryInstance | Registers an already-instantiated library object in the scripter. Prefer AddLibrary for normal use. |
| AddObject | Registers the object specified by AObject to be accessible from all scripts under the name AName. |
| AddVariable | Overloaded AddVariable(string, Variant) AddVariable(string, Extended) AddVariable(string, Double) AddVariable(string, string) AddVariable(string, WideString) AddVariable(string, Integer) AddVariable(string, Boolean) |
| BuildEventHandlerName | Builds a conventional script routine name for an event handler on the given component. |
| ClassByName | Same as Classes.ClassByName, please refer to TatClasses reference. |
| Clear | Reinitializes all internal structures, releases memory resources, and clears internal state. This method is automatically called before any compilation. |
| Compile | Compile the current script. See TatScript.Compile for more details. |
| DebugExecutionLine | Calls DebugExecutionLine for current virtual machine. See TatVirtualMachine.DebugExecutionLine. |
| DebugRunToLine | Calls DebugRunToLine for current virtual machine. See TatVirtualMachine.DebugRunToLine. |
| DebugRunToPoint | Calls DebugRunToPoint for current virtual machine. See TatVirtualMachine.DebugRunToPoint. |
| DebugRunUntilReturn | Calls DebugRunUntilReturn for current virtual machine. See TatVirtualMachine.DebugRunUntilReturn. |
| DebugStepOver | Calls DebugStepOver for current virtual machine. See TatVirtualMachine.DebugStepOver. |
| DebugStepOverLine | Calls DebugStepOverLine for current virtual machine. See TatVirtualMachine.DebugStepOverLine. |
| DebugToggleBreakLine | Calls DebugToggleBreakLine for current virtual machine. See TatVirtualMachine.DebugToggleBreakLine. |
| DebugToggleBreakPoint | Calls DebugToggleBreakPoint for current virtual machine. See TatVirtualMachine.DebugToggleBreakPoint. |
| DebugTraceInto | Calls DebugTraceInto for current virtual machine. See TatVirtualMachine.DebugTraceInto. |
| DebugTraceIntoLine | Calls DebugTraceIntoLine for current virtual machine. See TatVirtualMachine.DebugTraceIntoLine. |
| DeclareEventHandler | Inserts an event handler declaration in the script source for the procedure named AProcName.Returns the line number where code should be written, not the line of the declaration itself. |
| DefineClass | Same as Classes.DefineClass, please refer to TatClasses reference. |
| DefineClassByRTTI | Registers AClass and its members in the scripter using RTTI. |
| DefineFormClass | Registers the class of AForm in the scripter, exposing all owned components as properties of the form class. |
| DefineMethod | Registers a global method in the scripter, accessible from all scripts without an object prefix. |
| DefineProp | Registers a global property in the scripter, accessible from all scripts without an object prefix. |
| DefineRecord | Register a record structure to be used in Scripter like a class (see TatClasses.AddRecord) and define constructor/destructor methods. |
| DefineRecordByRTTI | Registers the record type specified by ATypeInfo in the scripter using RTTI. |
| EntryPoint | Calls EntryPoint for current virtual machine. See TatVirtualMachine.EntryPoint. |
| Execute | Executes the current script, compiling it first if necessary. |
| ExecuteSubroutine | Executes a specific routine declared in the current script, compiling it first if necessary. |
| ExpandDebugInfo | Calls ExpandDebugInfo for current script. See TatScript.ExpandDebugInfo. |
| ExpandedDebugInfo | Calls ExpandedDebugInfo for current script. See TatScript.ExpandedDebugInfo. |
| FindLibraryByClass | Searches for a registered library of the specified class and returns its instance, or nil if not found. |
| GetArrayIndex | Calls GetArrayIndex for current virtual machine. See TatVirtualMachine.GetArrayIndex. |
| GetInfoFromRoutineName | For internal use only. Do not use this method. |
| GetInputArg | Calls GetInputArg for current virtual machine. See TatVirtualMachine.GetInputArg. |
| GetInputArgAsBoolean | Calls GetInputArgAsBoolean for current virtual machine. See TatVirtualMachine.GetInputArgAsBoolean. |
| GetInputArgAsClass | Calls GetInputArgAsClass for current virtual machine. See TatVirtualMachine.GetInputArgAsClass. |
| GetInputArgAsDateTime | Calls GetInputArgAsDateTime for current virtual machine. See TatVirtualMachine.GetInputArgAsDateTime. |
| GetInputArgAsFloat | Calls GetInputArgAsFloat for current virtual machine. See TatVirtualMachine.GetInputArgAsFloat. |
| GetInputArgAsInt64 | Calls GetInputArgAsInt64 for current virtual machine. See TatVirtualMachine.GetInputArgAsInt64 |
| GetInputArgAsInteger | Calls GetInputArgAsInteger for current virtual machine. See TatVirtualMachine.GetInputArgAsInteger. |
| GetInputArgAsString | Calls GetInputArgAsString for current virtual machine. See TatVirtualMachine.GetInputArgAsString. |
| GetInputArgAsUInt64 | Calls GetInputArgAsInt64 for current virtual machine. See TatVirtualMachine.GetInputArgAsInt64 |
| GetInputArgAsWideString | Calls GetInputArgAsWideString for current virtual machine. See TatVirtualMachine.GetInputArgAsWideString. |
| GetRowColFromSource | Convert a script source position to a row and column information. |
| Halt | Calls Halt for current virtual machine. See TatVirtualMachine.Halt. |
| InProcessExecute | Calls InProcessExecute on the current virtual machine. See TatVirtualMachine.InProcessExecute for details. |
| InputArgCount | Calls InputArgCount for current virtual machine. See TatVirtualMachine.InputArgCount. |
| InstructionByLine | Calls InstructionByLine for current virtual machine. See TatVirtualMachine.InstructionByLine. |
| LoadCodeFromFile | Load compiled code from the file specified by AFileName parameter. |
| LoadCodeFromStream | Load compiled code from the stream specified by AStream parameter. |
| LoadLibrary | Loads and registers a library by name, searching Delphi-based libraries, script-based libraries, and file-based libraries. |
| LoadLibrary2 | Workaround for C++ automatic header generation. Calls LoadLibrary internally. |
| RemoveLibraryInstance | Removes a library instance previously registered with AddLibraryInstance. |
| RemoveProperty | Remove the property specified by the name AName. |
| ReturnOutputArg | Calls ReturnOutputArg for current virtual machine. See TatVirtualMachine.ReturnOutputArg. |
| SaveCodeToFile | Save compiled code in the file specified by AFileName parameter. |
| SaveCodeToStream | Save compiled code in the stream specified by AStream parameter. |
| SetInputArg | Calls SetInputArg for current virtual machine. See TatVirtualMachine.SetInputArg. |
| SetInputArgIfByRef | Calls SetInputArgIfByRef for current virtual machine. See TatVirtualMachine.SetInputArgIfByRef. |
| SilentCompile | Compiles the current script without raising an exception on error. |
| SolveAbsoluteAddressing | Calls SolveAbsoluteAddressing for current virtual machine. See TatVirtualMachine.SolveAbsoluteAddressing. |
| SystemLibrary | Returns the TatClass object representing the default system library with its built-in methods and constants. |
| UsesObject | Makes the methods and properties of AObject accessible directly from all scripts without an object name prefix. |
Properties
| Name | Description |
|---|---|
| AllowDLLCalls | Indicates whether scripts are allowed to call DLL functions directly using an external declaration. |
| BreakPoints | Provides access to BreakPoints property of current virtual machine. See TatVirtualMachine.BreakPoints for more details. |
| CallExecHookEvent | Enables OnExecHook event. If CallExecHookEvent is true, OnExecHook event is fired, otherwise it's disabled. CallExecHookEvent is false by default. |
| Classes | Holds the list of all Delphi classes registered in the scripter. |
| Compiled | Provides access to Compiled property of current script. See TatScript.Compiled for more details. |
| CurrentClass | Provides access to CurrentClass property of current virtual machine. See TatVirtualMachine.CurrentClass for more details. |
| CurrentDebugScript | Returns the script object used for debugging purposes, pointing to the original script even when a form instance creates a copy. |
| CurrentObject | Provides access to CurrentObject property of current virtual machine. See TatVirtualMachine.CurrentObject for more details. |
| CurrentScript | Gets or sets the currently selected (or currently executing) script in the Scripts collection. |
| DefaultInstances | Holds the list of default objects whose methods and properties are directly accessible from all scripts. |
| DeferObjectResolution | Indicates whether object method and property resolution is deferred from compile time to runtime. |
| EventBroker | EventBroker property provides access to the TatScripterEventBroker object which controls the binding between scripter and Delphi events. See TatScripterEventBroker class for more information. |
| FirstInstruction | Provides acess to FirstInstruction property of current script. See TatScript.FirstInstruction for more details. |
| Halted | Provides access to Halted property of current virtual machine. See TatVirtualMachine.Halted for more details. |
| LastExceptionClassName | Provides access to LastExceptionClassName property of current virtual machine. See TatVirtualMachine.LastExceptionClassName for more details. |
| LastExceptionHelpContext | Provides access to LastExceptionHelpContext property of current virtual machine. See TatVirtualMachine.LastExceptionHelpContext for more details. |
| LastExceptionMessage | Provides access to LastExceptionMessage property of current virtual machine. See TatVirtualMachine.LastExceptionMessage for more details. |
| LibOptions | LibOptions property holds a TScripterLibraryOptions object with configuration about how libraries are found and loaded in scripter environment. See TScripterLibraryOptions class for more information. |
| LoadFormEvents | Indicates whether the scripter automatically binds event handlers found in DFM files to matching script routines. |
| NextInstruction | Provides access to NextInstruction property of current virtual machine. See TatVirtualMachine.NextInstruction for more details. |
| OptionExplicit | Indicates whether variables must be explicitly declared before use in scripts. |
| Paused | Provides access to Paused property of current virtual machine. See TatVirtualMachine.Paused for more details. |
| pcode | Deprecated property. Don't use it. |
| Running | Indicates whether any script in the scripter is currently being executed. |
| SaveCompiledCode | Deprecated property. This should be always false. |
| ScriptBaseObjectClass | Gets or sets the base class used when a script-based class is instantiated. Defaults to TScriptBaseObject. |
| ScriptFormClass | Gets or sets the class used to create form instances from script. Defaults to TScriptForm. |
| ScriptInfo | Provides access to ScriptInfo property of current script. See TatScript.ScriptInfo for more details. |
| Scripts | Holds the collection of all scripts managed by this scripter component. |
| ShortBooleanEval | Indicates whether boolean expressions use short-circuit evaluation, stopping as soon as the result is known. |
| SilentCompiled | Provides access to SilentCompiled property of current script. See TatScript.SilentCompiled for more details. |
| SourceCode | This property provides access to the SourceCode property of current script. See TatScript.SourceCode for more details. Compilation is NOT called automatically when changing this property. |
| Watches | Holds the collection of watches used for evaluating expressions during script debugging. |
Events
| Name | Description |
|---|---|
| OnBeforeExecute | OnBeforeExecute is called before a script routine (or main block) is executed. ALabel contains the name of the routine to be executed. If the main block is to be executed, ALabel is an empty string. |
| OnBreakpointStop | OnBreakpointStop event is fired whenever a breakpoint is reached in a script execution, and the execution goes to paused state. |
| OnCompileError | OnCompileError event is fired whenever an error occurs during a script compilation. |
| OnDebugHook | Fired repeatedly while the script execution is paused, allowing the application to update its UI. |
| OnExecHook | OnExecHook event is called during scripter execution. It's a callback event that you can use for performing operations while a script is being executed. For performance reasons, OnExecHook is only called when CallExecHookEvent property is true. |
| OnPauseChanged | OnPauseChanged is fired whenever Paused property value is changed. |
| OnRunningChanged | OnRunningChanged event is fired whenever value of Running property changes. |
| OnRuntimeError | OnRuntimeError event is fired whenever a runtime error occurs during a script execution. |
| OnSingleDebugHook | Fired once whenever the script execution is paused or a debug step action is performed. |
| OnUnknownElement | Fired during script compilation when the compiler encounters an unrecognized identifier. |