Xbase Documentation

Using Scripts

Scripts are used to automate repetitive or time-consuming tasks. They can also be used to make forms more dynamic. Scripts are written in JavaScript, although some functions are not supported (the javascript DOM functions for instance).

Learning JavaScript
If you do not already know JavaScript, we recommend parts 1 and 3 of "JavaScript: The Definitive Guide (5th Edition)" by David Flanagan.

We also recommend the Mozilla JavaScript developer center, which features comprehensive documentation of all JavaScript objects and functions, as well as a guide: http://developer.mozilla.org/En/JavaScript

Basics
To create a script, click the plus button in the scripts section in the overview. Alternatively, select scripts in the source list and click the plus button at the bottom left of the window.

This is the hello world program in Xbase Scripts:
Tools.Alert("Hello World");

To run a script, click the circular green "Run" button in the toolbar.

The Console
The Console displays the output from scripts. It may be shown and hidden either by clicking the "Console" button in the toolbar, or by clicking the arrow in a box in the button bar.

Two methods are provided for writing to the console. The Tools.Print method will simply print any string passed to it and will not insert any newlines.
Tools.Print("displayThis");

The Tools.Log method will insert a newline, display the time and date and then print the string passed to it.
Tools.Log("displayThis");

To clear the console, click the "Clear" button in the toolbar.

Documentation
Documentation for all functions in the scripting API is available here.

Integrating with Forms
Scripts can be integrated with forms. They can be set to run when controls are pressed and can interact with the form by changing the attributes of controls. Script-Form Integration is described here.

Editing Externally
You can edit a script in your favourite text editor by clicking the "Edit Externally" popup button in the toolbar. Then just type in the text editor and save to update the script. Keep in mind that switching tabs or navigating away from the script editor will close the external editing session. Any further changes after this will not affect the script.

All other functions of the editor apart from changing the script's text are maintained while externally editing.

Miscellaneous Features
You can enable autocomplete by pressing escape. This will show a list of keywords, class names and method names which you can narrow down as you type.

The plus button on the left of the editor's button bar will create a new javascript function literal.

Syntax Highlighting and Formatting
Syntax highlighting shows roughly what code does. You can set up syntax highlighting in the "Script Editor" preferences. The highlighting style menu provides presets from several popular editors. The hue change wheel allows you to change the color scheme of all settings at once. Lastly, you can change the font used by clicking the Select button.