Tabular IQ

Developer Resources

Developer Home

API Overview

The scripting API uses classes to define a rich set of capabilities: creating GUI elements such as forms with a native look and feel, accessing and manipulating databases, interfacing with the web, and more.

The class categories divide roughly into four groups: classes for basic language operations, classes for creating interfaces, classes for accessing and manipulating information, and classes for interacting with the system and the host application.

The basic language operations are covered by the standard core JavaScript classes. Interfaces are built with the classes in the Application, Dialog, Form, Control, Layout, and Graphics categories. Information access lives in the Input/Output, XML, DOM, Network, Database, and Encryption categories. And the System and Host Application categories cover interaction with the machine and with Tabular IQ itself.

The full reference is in Classes by Category; what follows is an overview of the major categories and some important classes in each.

Core

The Core category contains the foundational classes used to manipulate strings, numbers, dates, boolean values, arrays, and basic objects.

For example, with the String class you can concatenate strings, split them, extract substrings, or match and replace portions of them. With the Array class you can store collections, add and remove elements, sort, and iterate.

Application

The Application category contains the classes essential for creating and interacting with script-defined interfaces: the Application class and the Event classes.

The Application class starts and stops the script event loop, which drives the user-interface portion of a program and connects your code to the user’s actions. Only scripts that process events need it, and it appears right after the main form is created and shown:

const f = new Form();
f.show();
Application.run();

While Application runs the event loop, the Event class is the base class for the events being processed, such as mouse events. Events are connected to handler methods with connect():

button.click.connect(this, this.onButtonClicked);

Dialog

The Dialog category contains classes for stock dialogs: opening and saving files, entering text or passwords, and selecting colors. Dialogs are self-contained — they don’t need the Application event loop to run.

To show a file-open dialog for selecting images:

// create a new file dialog object
const dlg = new FileDialog();

// show these file types in the dialog's filter
dlg.setFilter("Bitmap Files|*.bmp|JPEG Images|*.jpg;*.jpeg");

// show the dialog, and use the results only if
// the user pressed Ok
if (dlg.showDialog() == DialogResult.Ok)
{
    for (const file of dlg.getPaths())
        alert(file);
}

Form

The Form category contains classes for creating top-level forms that contain other controls, as well as for creating and manipulating menu bars, toolbars, and status bars.

Control

The Control category contains the controls that are added to forms: buttons, text controls, web controls, tree controls, list controls, and other interface elements. By extending the FormControl class, you can also create controls of your own.

Here’s a form with a button that closes the application when clicked:

// define our own class derived from Form
class MyForm extends Form
{
    constructor()
    {
        // call the constructor on the base class Form
        super("Button Example", 100, 100, 200, 100);

        // create a button and add it to the form
        const button = new Button("Exit", 60, 20, 80, 24);
        this.add(button);

        // when the button is clicked, call the onButtonClicked
        // event handler on this class
        button.click.connect(this, this.onButtonClicked);
    }

    onButtonClicked()
    {
        // when the button is clicked, exit the application
        Application.exit();
    }
}

const f = new MyForm();
f.show();
Application.run();

Layout

The Layout category contains classes for laying out controls on a form, so interfaces adapt to resizing instead of using fixed pixel positions.

Graphics

The Graphics category contains classes for drawing to the device context of a form.

Input/Output

The Input/Output category contains classes for reading and writing text and binary files.

XML

The XML category contains a class for accessing information in XML.

Document Object Model (DOM)

The DOM category contains classes for accessing and manipulating the document object model.

Network

The Network category contains classes for issuing HTTP requests and transferring data via FTP and SFTP.

Database

The Database category contains classes for connecting to databases — such as Oracle, MySQL, or Tabular IQ’s own database — and working with the data inside them: creating tables, selecting, inserting, updating, and deleting.

The main classes are DbConnection and DbResult. DbConnection connects to a database and executes SQL commands; DbResult iterates the rows a query returns.

Here’s how to connect to the local project database, create a table, and read it back:

// connect to the local project database;
// HostApp.getDatabase() returns a DbConnection object
const db = HostApp.getDatabase();

// create a table
db.execute("CREATE TABLE mytable (field1 VARCHAR(80));");

// add some rows
db.execute(`
    INSERT INTO mytable (field1) VALUES ('111');
    INSERT INTO mytable (field1) VALUES ('222');
    INSERT INTO mytable (field1) VALUES ('333');
`);

// update the application's project panel so the newly
// created table appears there
HostApp.refresh();

// select the rows and display the values
const result = db.execute("SELECT * FROM mytable");

while (result.next())
{
    alert(result.field1);
}

Encryption

The Encryption category contains classes for encrypting and hashing strings. For example, the Hash class computes an MD5 hash:

const text = "The hash of this text is: ";
alert(text + Hash.md5(text));

System

The System category contains classes for interacting with the computer the script runs on: system settings and metrics, fonts, colors, and loading shared libraries such as DLLs.

For example, to show the default system directories:

const output = `Documents path: \t${Environment.getDocumentsPath()}
System path:    \t${Environment.getSystemPath()}
Temporary path: \t${Environment.getTempPath()}`;

alert(output);

Host Application

The Host Application category contains classes for interacting with the application the script runs inside — Tabular IQ itself. With the HostApp class you can add items to menus, add forms to dockable panes, manipulate open documents, and more. This is the category that powers extensions.

For example, to list all open documents:

// HostApp.getDocuments() returns an array of HostDocument objects
const documents = HostApp.getDocuments();

let locations = "The documents currently open are:\n\n";
for (const doc of documents)
    locations += doc.getLocation() + "\n";

alert(locations);

Next steps