Tabular IQ

Developer Resources

Developer Home

Creating and Running Scripts

Tabular IQ scripts are a little different from the scripts you may know from web pages. Rather than being embedded in HTML, a script is a standalone text file containing JavaScript, which can be run as a program in its own right or packaged into an extension.

Creating a new script

To create a basic script that shows a message:

  1. From the File menu, choose New → Script. A blank text editor opens.
  2. Enter the following code:
alert("test");

Saving and running within a project

To save the script to your project and run it:

  1. Choose File → Save As.
  2. In the save dialog, enter a name such as test_script and click Save.
  3. Run the script by choosing Run Script/Query from the Tools menu, or by pressing Alt+Enter.

Saving to the file system

Scripts don’t have to live inside a project. To save a script as an ordinary file:

  1. Choose File → Save As External.
  2. Save the file as you would in any other application.

Where scripts are stored

When a script is created inside a project, the script file is managed directly by the project and is not readily accessible to other applications on the file system. When a script is saved externally, it is an ordinary file on disk, easily accessible to text editors, source control, and other tools.

Choosing between the two

Project scripts work well when a script is closely tied to the tables and queries of a particular project — for example, a script used regularly as part of a working system, where it shouldn’t be accidentally moved or separated from the data it operates on.

External scripts are the better choice when you want to edit with your own text editor, keep scripts in source control, or share them with other people. See Managing Scripts for how to work with external script folders from inside the project panel.

Next steps