Overview
TMS Scripter is a set of Delphi/C++Builder components that add scripting capabilities to your applications. With TMS Scripter your end-user can write his own scripts using visual tools and then execute the scripts with the scripter component. The main components available are:
TatScripter: Non-visual component with cross-language support. Executes scripts written in both Pascal and Basic syntax. This is the component you will use in most applications.
TIDEScripter: A TatScripter descendant with the same scripting capabilities, plus the integration needed by the ready-to-use IDE (form designer, object inspector, debugging).
TScrMemo: Lightweight syntax highlight memo, that can be used to edit scripts at run-time.
The TatPascalScripter and TatBasicScripter components (single-language scripters for Pascal and Basic respectively) are still available for backward compatibility, but new applications should use TatScripter, which handles both languages.
All scripter components (in this document collectively referred to as Scripter) descend from TatCustomScripter, which holds the common properties and methods for script execution. The scripter has the following main features:
- Run-time Pascal and Basic language interpreter;
- Access any Delphi object in script, including properties and methods;
- Supports
try..exceptandtry..finallyblocks in script; - Allows reading/writing of Delphi variables and reading constants in script;
- Allows access (reading/writing) script variables from Delphi code;
- You can build (from Delphi code) your own classes, with properties and methods, to be used in script;
- Most of Delphi system procedures (conversion, date, formatting, string-manipulation) are already included (IntToStr, FormatDateTime, Copy, Delete, etc.);
- You can save/load compiled code, so you don't need to recompile source code every time you want to execute it;
- Debugging capabilities (breakpoint, step into, run to cursor, pause, halt, and so on);
- Thread-safe;
- COM (Microsoft Common Object Model) Support;
- DLL functions calls.
In addition to the scripting engine, a full Integrated Development Environment (IDE) is to edit scripts, design forms, debugging, and many other operations with Delphi/Visual Studio look and feel for both creating and running script projects. The following features are present in the IDE:
- Full IDE environment dialog;
- Visual form designer;
- Component palette and palette buttons with Delphi 2007 style;
- Integrated syntax memo with built-in code completion and breakpoint features.
Rebuilding Packages
If for any reason you want to rebuild source code, you should do it using the "Packages Rebuild Tool" utility that is installed. There is an icon for it in the Start Menu.
Just run the utility, select the Delphi versions you want the packages to be rebuilt for, and click "Install".
You can also rebuild the packages manually by opening the dpk/dproj file in the Delphi/RAD Studio IDE.
Use in Firemonkey applications
The TMS Scripter engine can be used in Firemonkey applications. You can execute scripts in FM applications even with forms.
But note that several VCL components don't have Firemonkey equivalents yet, especially the visual ones, so the scripter IDE (form designer, syntax memo, object inspector, etc.) are not available for Firemonkey applications.
All you need to do in your Firemonkey application is add unit
FMX.ScripterInit to your project or the uses clause of any unit. Then
you can use the scripter component normally just as you would do with in
VCL (see chapter Working with Scripter).
There are several demos in TMS Scripter distributing showing how to use it with Firemonkey application, including manual debugging.
In this section:
Working with scripter
Using the scripter component in your application: running scripts, calling subroutines, passing parameters, loading script libraries and debugging.
Extending scripter
Integrating scripter with your application: registering classes, methods, properties, functions, variables and libraries so scripts can use them.
Writing scripts
For the script author: the supported languages and their syntax, plus declaring forms and classes in script and reusing one script from another.
Pascal syntax
Basic syntax
Calling DLL functions
Integrated Development Environment
The ready-to-use IDE for writing scripts and designing forms, available for VCL applications.
The syntax highlighting memo
Using the TAdvMemo control that provides syntax highlighting for Pascal and Basic scripts.
C++Builder Examples
C++Builder examples equivalent to every Delphi example in this guide.