Program Script Task


The Program Script Task is an extended feature in X-Pert Graphics, which not only gives you the opportunity to write program scripts for all the  tasks that can be done in X-Pert Graphics by writing a code for them but it also allows you to make your projects even more functional and user friendly. Note that in order to take full advantage of this X-Pert Graphics option, you need to be an advanced user of the program and you must have at least a basic programming knowledge.

This X-Pert Graphics feature supports four different language syntaxes:

Pascal script

C++ script

Visual Basic script

Java script

TIP (!): Considering the X-Pert Graphics functionality, it is advisable that you use Pascal or C++ script, instead of Visual Basic or Java script. Since you always have to declare the type of a variable in Pascal and C++, the latter are more thorough in terms of avoiding mistakes. In Visual Basic and Java script, on the other hand, new variables are not defined in terms of their type. They simply adopt the variant type and can accept all kinds of variables, no matter if they are string, integer, etc., throughout your script, which inevitably becomes a prerequisite for errors.

Please, be aware that X-Pert Graphics’s Program Script Task does not support all the functionalities that each of the programming languages, listed above offers. All the classes, functions, types, and variables that this interface supports, are listed in the tree view, situated in the right area of the Create Program Script window.

IMPORTANT! X-Pert Technology, does NOT offer support for third party scripts, developed with the Program Script Task. This function should be used at the sole responsibility of the corresponding third party developer.



User Interface

Work Area

Pressing the Program Script  button in the Task Manager window invokes the following user interface:

1. Program View

This is the area, marked with number ‘1’ in the picture above. This is the place, where the user enters their script. Depending on the programming language, selected from the Language drop-down menu above it, the script will automatically load a language identifier in the beginning of the script window, which is in the following format: [#language Pascal/C++/Basic/Java], depending on the language selected.

Note that the grey area to the left shows certain events, added manually in the script, like Execute next step, and Toggle breakpoint, as explained in the Toolbar section below.

Also, the grey area at the bottom of the program script view shows the position of the cursor, [13:1] in this example. This information is useful when debugging, since the errors are indicated in accordance to these position coordinates in the Debug view.

2. Browser View

This is the area, marked with number ‘2’ in the picture above. This view shows you a list of all the [Classes], [Functions], [Types], and [Variables], available for you to include in your program script. You can expand/shrink the list of each of the above items by pressing the plus/minus sign next to it, or by double-clicking on them.

The Tree View supports drag-n-drop and double-click functionalities, as explained below:


If you drag-n-drop an item, designated with  or  in the program script, only the class type will be implemented in the script. For example, if you drag-n-drop the [TWinControl = class(TControl)] to the script, only [TWinControl] will be implemented in the script view.

If you drag-n-drop an item, designated with or  in the program script, the whole line will be implemented in the script. Thus, if you drag-n-drop the [property Cursor: Integer], the whole [property Cursor: Integer] line will be placed in the script view.


Besides drag-n-dropping, you can also double-click on the items from the Tree View. If you double-click on a  or a , the list will correspondingly expand or shrink.

If you double-click on an item, designated with or  on the other hand, it will appear in your script as a name and brackets next to it with the appropriate number of places for you to fill in, separated by commas. For example, if you double-click on the function [DirectoryList(const Path: String; List: TStrings)], the following will be implemented in the program script: [DirectoryList(,)].

The Browser area is only visible while the Browser box in the toolbar is checked.

3. Watch View

This is the area, marked with number ‘3’ in the picture above. It allows you to have an additional control over your program via “watching” how your variables behave in your script.

The watch area consists of three columns:

Watch Name – this column shows the name of the item/variable that is being watched

Type – this column shows the type of the corresponding item/variable (like integer, string, float, etc.)

Value – this column shows the current value of the corresponding item/variable. Note that if the script has been executed up to a certain line only, the entry will represent the value of the item until this step

Right-clicking on any line in this area will invoke the following context menu:

If you select Add or Edit, the Watch Properties dialog will open. Another way for invoking this dialog is by pressing <Ctrl> + <F7>. In the Expression field enter the name of the item you wish to watch. Select the type of the variable by pressing one of the radio buttons below. If you choose Auto, the type of the variable will be obtained automatically from the script, if possible. If you wish to transform the result in another value type, you can select a type, different from the default type of your variable, as long as the two types are compatible.

Checking the Enabled box will add a check-box to the corresponding row in the Watch List. The idea of this check-box is to give the user the ability to control which variables should be “watched,” and which should not be “watched” at a time. Thus, if an item is not checked, its value in the Value column will not be changed until the box next to it is checked back.

The Delete and the Clear commands from the context menu are self-explanatory.

The Watch area is only visible when the Watch box in the toolbar is checked.

4. Debug View

This area shows all the syntax errors that appear in the script while debugging. Note that logical errors will not be traced by the script engine.

The Debugmode is only active when the Debug box in the toolbar is checked.

NOTE: The X-Pert Graphics script engine allows you to check whether or not you are in Debug mode via a special variable, named [DEBUG], which is of type Boolean. When [DEBUG = True], this means that you are in Debug mode, and when [DEBUG = False], the Debug mode is off, so the script is executed without interruptions. Please, check Example 13 in Appendix 7 below.


Use the drop-down menu in the toolbar for selecting the programming Language, in which you are going to write your script. Your options are Pascal, C++, Basic, and Java.

Several buttons and check-boxes are situated after the drop-down menu. Their functions are as follows:

 - This is the Insert button. It is used for inserting Modules, Objects, Slides, Tasks, and Data Providers. When you press the black arrow next to it, a context menu will appear:

Here you can select the type of the item you would like to insert in your script. Notice that there is a combination of keys written next to each item. Thus, instead of clicking on the respective item from the Insert drop-down menu, you can simply enter the corresponding key combination. Furthermore, note that in the screenshot above the second line [Object] is marked with a bold font. This means that when you press only the Insert  button instead of the arrow next to it, an Object will be added to the script. If, next time you insert an item you select [Slide] from the context menu, its line will be bolded and a Slide will be added after clicking only the button instead of the arrow.

If you select the Use module option from the context menu above, you can insert any script, situated in X-Pert Graphics’s Library, regardless of the language, in which it is written. This option is very useful if you need to use the same function in different scripts. Please, check Example 15 in Appendix 7 below to see how modules are inserted in different script syntaxes.

 – Use the New button to clear the Program View and start working on a new script.

 – Use the Open Script in editor button to load an already saved script.

 – Use the Save Script to file button to save your script.

 – Use the Undo changes button to undo your latest changes. You can also press the <Ctrl>+<z> keys instead of this button. Up to 60 steps can be reversed.

 – Use the Run Script button to debug your entire script. You can also press the <F9> key instead of this button.

 – Use the Execute next step button to only execute the line after the one, where the cursor is situated. You can also press the <F8> keys instead of this button.

In the example above, please notice the light-blue line with a green arrow in the beginning. After a step is executed via the button, described above, this step is marked like that.

 – Use the Stop execution button to stop debugging your script. You can also press the <Ctrl>+<F2> keys instead of this button.

 – Use the Toggle breakpoint button to insert a breakpoint in the script. You can also press the <F5> key instead of this button. When a breakpoint is added, the next time you start executing your script, it will pause executing at that breakpoint.

In the example above, please notice the red lines with a red circle in the beginning. After a breakpoint is included, the line that corresponds to the breakpoint will be marked like that.

Also, be aware that you can add a breakpoint also by clicking in the grey area to the left of the script view. If you want to remove that breakpoint, simply click on it again.

 Debug – If checked, the script will be debugged when executed. Otherwise, only the final result will be shown and no messages will appear in the Debug area at the bottom.

 Watch – If checked, the Watch area will be visible.

 Browser – If checked, the Browser area will be visible.

 - The Evaluate expression button invokes the dialog, shown below. In the Expression field you can enter different mathematical expressions, in which you can include variables from your script. After pressing <Enter>, the program will show you the result of the expression in the Result field. If you have entered a variable and/or other symbol that cannot be recognized by the script engine, it will return an error message in the latter field.

Menu Bar 


The File menu consists of an Open, Save, and an Exit command, which are all self-explanatory. Be aware that your script can be automatically executed if you Save it under a name, recognized by X-Pert Graphics. Check the Auto-executed Scripts function, described below.


The edit menu consists of several commands. The first three, Cut, Copy, and Paste, are self-explanatory.

The Insert command is the same as the insert button, explained above in the Toolbar section.

The Open file at cursor command simply allows the user to load a script at the current location of the cursor. As visible in the screenshot above, this command can also be invoked with the <Ctrl>+<Enter> key combination.

The Browser Window command is the same as the Browser checkbox in the Toolbar, explained above.


The Execute menu is very similar to the Toolbar, explained above. However, it offers some additional commands, explained below. Also, it shows the equivalent keyboard buttons that could be used for the commands.

The Run to Cursor command is not included in the toolbar. When selected, this command will execute the script to the point, where the cursor is currently situated.

This menu also offers an additional function for the Toggle breakpoints. If you go to Breakpoints, a context menu will be opened, from which you can either add a breakpoint (Toggle command), or remove all breakpoints, via the Clear All commands.

If checked, the Auto add Variables option will automatically add all variables used in the script to the Watch View at the bottom of the Create Program Script dialog.