Other > Scripting > Scripting Overview > Creating a Qt Script

Creating a Qt Script

Use the Script Editor to create Qt scripts for Harmony.

For all details about the scripting modules, methods, and DbScript documentation, click on the links below.

Harmony Script Interface Documentation
Script Module Documentation
DbScript Documentation

This section is divided as follows:

Creating a Script
Deleting a Script
Troubleshooting a Script

Creating a Script

To create a script:

1. Open the Script Editor by going to the top menu and selecting Windows > Script Editor.

The Script Editor view opens listing all the JavaScript files.

Script Editor View

2. From the view menu, select File > New Script or from the Script Editor toolbar, click on the New Script New Script Button button. (If you do not see the Script Editor toolbar, go to the top menu and select Windows > Toolbars > Script Editor).

The New Script dialog box appears.

New Script Dialog Box

3. Enter a name in the Enter name of new script field and click on OK.

The name of your script appears in the File column of the Script Editor view.

New Script File

4. Click in the right side of the Script Editor and start writing your script. Try typing in the following script:

function add3dPathCol()

{

column.add(“ColumnName”, “3DPATH”);

}

For a tutorial on coding in JavaScript, refer to the following:

http://docs.oracle.com/javase/tutorial/java

For a detailed Harmony script interface documentation, refer to the following:

Harmony Script Interface Documentation
5. To check your syntax, click on the Verify button.

A window opens with syntax information.

Syntax Error

6. To test your script, select the script you would like to run from the File column, then, from the Script Editor toolbar, click on the RunRun Script Button button, or from the view menu select Play/Debug > Run.
A window opens to ask you for the target function to run. In the window, select which function you want to execute. To avoid selecting the function every time you want to run your script, you can set a target function. In the Script Editor toolbar, click on the Set TargetSet Target Function Button button, or from the view menu select Play/Debug > Set Target. In the Function column, select the function to target and press OK.

Set Target Function Window

To stop the execution of your script, click on the Stop ExecutionStop Script Execution Button button.
You may receive the message: Only functions that have been saved or are explicitly called will be executed. This usually occurs if you did not select the function you wished to run from the File column before running the script. In this case, click on the Save Changes button, then try running your script again.
You may also see this message on the right side of the Script Editor:

Script Editor Sandbox Message

This is because the software jumped to the <<Sandbox>> item in the Function column. The <<Sandbox>> is provided to test scripts without saving them. Simply click on your newly created script and then try running it again.

Deleting a Script

Troubleshooting a Script

If you are working in a Network Environment, see Creating a Qt Script