Working with ogScript

ogScript is a programming language developed by Ross Video to interact with DashBoard-enabled devices. It is a subset of JavaScript, with PanelBuilder-specific functions added.

In PanelBuilder, you can add advanced functionality and logic to CustomPanels by creating Component Tree items that execute ogScript code.

This section contains the following topics:

Adding an ogScript-Based Item to the Component Tree

Editing ogScript Code

Adding an ogScript-Based Item to the Component Tree

The following types of Component Tree items can include ogScript code segments:

api items (<api/> tags)

An api item is a collection of ogScript functions that can be accessed from anywhere in the CustomPanel. You can also create a separate API script file to make the functions available to multiple CustomPanels.

ogscript items (<ogscript/> tags)

An ogscript item is a standalone segment of ogScript code that can be referenced from within the CustomPanel.

task items assigned to panel components

ogScript tasks can be assigned to buttons, labels, parameters, listeners, and timers (timertask item).

Creating an API Item in the Component Tree

To create an API with callable functions:

1.In the Insert Tag area above the Component Tree, click the <api/> button.

A new api item appears within the highest level container item (usually abs) in the Component Tree.

2.On the Api Attributes tab, in the General Attributes area, specify a Name and an ID for the new API.

3.If you want the script in the API to be executed immediately, before the rest of the panel is loaded, select the Execute Immediately check box.

When this option is selected, the script in the <api/> tag is evaluated as soon as it is reached, during the panel build process. This allows the script to create global functions that can be called from anywhere in the panel, create new parameters on the fly, and modify constraints of parameters even before they are displayed.

For more information about creating an API, see Creating Internal and External APIs.

4.Specify other attributes as needed. For more information, see Api Attributes Tab.

5.Do one of the following:

If you want to create the ogScript functions manually, click the ogScript button, and then type or paste the ogScript code into the ogScript Editor.

For more information about editing ogScript manually, see Editing ogScript Code.

For detailed reference information about ogScript functions, see the DashBoard CustomPanel Development Guide (8351DR-007).

If you want to create the ogScript functions visually, click the Visual button and then add the new functions.

For more information about adding functions, see Creating New Functions.

For more information about using the Visual Logic editor, see DashBoard Visual Logic.

6.Click Apply Changes or Apply and Close.

Creating an ogscript item in the Component Tree

To create an ogscript item in the Component Tree:

1.In the Edit Component window, in the Insert Tag area above the Component Tree, click the <ogScript/> button.

A new ogscript item appears within the highest level container element (usually abs) in the Component Tree.

2.On the Ogscript Attributes tab, in the General Attributes area, specify a Name and ID for the ogScript code segment.

3.Specify other attributes as needed. For more information, see ogScript Attributes Tab.

4.Do one of the following:

If you want to create the ogScript code manually, click the ogScript button, and then type or paste the ogScript code into the ogScript Editor.

For more information about editing ogScript manually, see Editing ogScript Code.

For detailed reference information about ogScript functions, see the DashBoard CustomPanel Development Guide (8351DR-007).

If you want to create the ogScript code visually, click the Visual button and then add and connect logic blocks to create the code.

For more information about using the Visual Logic editor, see DashBoard Visual Logic.

5.Click Apply Changes or Apply and Close.

Creating an ogScript Task Assigned to a Panel Component

To create an ogScript task assigned to a panel component:

1.Create the panel component to which you want to assign the new ogScript task (button, label, parameter, listener, or timer).

In the Edit Component window, in the Component Tree, click the component to which you want to assign the task.

The Attributes tab for the component type appears.

2.In the Tasks area, click Add.

The Add Task window appears, with the Task Type set to ogScript.

3.Do one of the following:

If you want to create the ogScript code manually, click the ogScript button, and then type or paste the ogScript code into the ogScript Editor.

For more information about editing ogScript manually, see Editing ogScript Code.

For detailed reference information about ogScript functions, see the DashBoard CustomPanel Development Guide (8351DR-007).

If you want to create the ogScript code visually, click the Visual button and then add and connect logic blocks to create the code.

For more information about using the Visual Logic editor, see DashBoard Visual Logic.

4.When you are finished creating the code, click OK.

5.Click Apply Changes or Apply and Close.

Editing ogScript Code

You can edit ogScript code manually, or use the Visual Logic editor to edit it visually.

This section describes how to edit ogScript code manually. For information about editing ogScript code visually, see DashBoard Visual Logic.

ogScript is a programming language developed by Ross Video to interact with DashBoard-enabled devices. It is a subset of JavaScript, with PanelBuilder-specific functions added. Editing ogScript code requires JavaScript coding skills.

When you edit ogScript code manually, you do it in one of the following interfaces:

Source tab — text editing only.

Manual ogScript editor — text editing plus use of the script palette, which is a tool that enables you to drag pre-made code templates into the current code segment.

Note: If you create or edit a segment of ogScript code manually, you cannot later edit that code in the Visual Logic editor.

To create or edit ogScript manually:

1.Create a CustomPanel, and add an ogScript-based item to the Component Tree.

For more information, see Adding an ogScript-Based Item to the Component Tree.

2.In the Component Tree, click an ogScript-based item (api, ogscript, task, or timertask).

3.If you want to edit the code on the Source tab (text only), click the Source tab.

The Source tab shows the source code for the item that is selected in the Component Tree. If the selected item is ogScript-based, the Source tab shows the OGLML element for the item (api, task, ogscript, timertask). Place your ogScript code between opening and closing tags of the element.

4.If you want to edit the code in the manual ogScript editor, click the Attributes tab for the item (for example, Task Attributes), and then click the ogScript button.

The manual ogScript editor shows the ogScript code for the item selected in the Component Tree.

Tip: To use the script palette, select the script palette check box. For more information, see Using the Script Palette.

Using the Script Palette

The script palette is a tool that enables you to quickly add pre-made ogScript command templates, which you can customize to produce code more quickly and with fewer coding errors.

Templates enable you to more easily create ogScript functions, manipulate parameters, etc.

The script palette is available within the manual ogScript editor.

scriptPalette.png 

Figure 1.33  - The Script Palette

To access the script palette:

In the manual ogScript editor, select the Script Palette check box.

The script palette dialog box appears.

 

To use the script palette:

1.In the workspace of the manual ogScript editor, click the position where you want to insert a command template.

2.In the script palette, click the tab that contains the command template you want to use (params, Basic Scripting, ogscript, Param List).

3.If you are using the Param List, select whether you want to Get a value or Set a value.

4.Click and drag the command or parameter into the editor workspace.

The template code appears.

5.Edit the code, replacing the colored placeholders as required.

Using the Search Tool

The manual ogScript editor includes a search tool, which enables you to find instances of the specified text within the current ogScript code segment.

To use the Search tool:

Type the string in the Search box, and then click Find Next.

To immediately find the same string again, press Enter.

To move the cursor into the Search box, press Ctrl+f.