This section describes the Visual Logic editor.
The Visual Logic editor is available only when you are editing a segment of ogScript code. To access the Visual Logic editor, you must first create a CustomPanel that includes an ogScript code segment, and then select the Component Tree item that represents that ogScript code segment. The following Component Tree items are ogScript code segments: api, ogscript, task, and timertask.
For demonstration purposes, the following procedure describes how to create an ogScript code segment (in this case, a task item in the Component Tree) so you can view the Visual Logic editor:
To view the Visual Logic editor (an example):
1.Create a new CustomPanel.
2.In Edit Mode, add a button to the CustomPanel.
3.Double-click the button to edit it.
4.The Edit Component window appears.
Note that the button item is highlighted in the Component Tree.
5.In the Tasks section, click Add.
The Add Task window appears.
The Visual Logic editor is open by default. You can use it to create the ogScript code.
Tip: Whenever the Visual Logic editor is open, the Visual button is highlighted blue.
6.When you are finished creating the ogScript code, click OK, and then click Apply Changes.
Note that the new task item appears within the button item in the Component Tree.
Figure 1.2 - Edit Component Window showing the Visual Logic Editor
Visual Logic Editor - Areas and Controls
The Visual Logic editor includes the following areas and controls:
The Visual button changes the ogScript Content area to show the Visual Logic editor.
Whenever the Visual Logic editor is open, the Visual button is highlighted blue.
Note: If the ogScript code has been edited outside of the Visual Logic editor, you cannot use Visual Logic to view or edit it.
The ogScript button changes the ogScript Content area to show the manual ogScript editor.
Note: If you edit an ogScript code segment outside of the Visual Logic editor, you cannot later use Visual Logic to view or edit it.
The Show/Hide Panels button reveals or hides the Devices and Parameters panel, the Local Variables panel, and Control and APIs panel. Temporarily hiding these panels enables you to see more of the Visual Logic workspace. These panels list logic blocks that you can add to the Visual Logic workspace.
The Auto Arrange button organizes all logic blocks in the workspace neatly.
The Undo button reverses the most recent action performed.
The Redo button reverses the action of the Undo button. If you click Undo but then change your mind, click the Redo button.
Some logic blocks associated with devices include icons to help you visually identify the block types. Use the icon size list to set the display size of these icons.
The Search box enables you to find a particular logic block, or cycle through a set of similar logic blocks.
To find a particular logic block in the workspace, type a search string in the Search box, and then press Enter. The search string can be any text that appears on the block, such as part of the name of the block, or data in the block.
If the search yields results, one logic block that satisfies the search criterion is highlighted. To view another match, click the Find Next button.
To exit Search mode, click the small x icon beside the Search box.
Tip: You can also search by block ID. Block IDs are unique identifiers assigned to code blocks. You can view block IDs on the Source tab. To search for a given block, for example block 1777, type block: 1447 in the Search box and then press Enter. If the block is part of the current ogScript code segment, it is highlighted in the workspace.
The Find Next button is used in conjunction with the Search box. Click the Find Next button to show another logic block that satisfies the search criterion.
The Devices and Parameters panel lists API functions and parameters associated with devices and panel parameters.
Devices:
•Expand the name of a device to reveal its API functions and/or parameters. You can drag the functions and parameters into the workspace to use them in your ogScript code. The functions and parameters are designed to provide control of the device.
•To add a device to the list, click the green + icon, select a device type, and then specify properties of the device.
•You can add devices from the DashBoard tree, or add a new device of one of the following types: Acuity, CamBot, PBus, VDCP, and XPression.
•Tip: You can also create an entirely new device type. For more information, see Creating a New Device Type in Visual Logic.
Panel Parameters:
•Expand Panel Parameters to reveal a list of the parameters available in the CustomPanel. You can drag parameters into the workspace to use them in your ogScript code. Parameter values can be routed to other logic blocks for logical operations.
Note: The Panel Parameters folder is visible only if your CustomPanel includes panel parameters.
•For information about creating new panel parameters, see Parameters and Data Sources.
Search:
•The Search box enables you to find API functions or parameters that have names containing the search string.
•To search, type a search string in the Search box, and then press Enter. The list is filtered to show only logic blocks that satisfy the search criterion.
•To exit Search mode and view the entire list, click the small x icon beside the Search box.
The Local Variables panel lists variables that can be used within the current ogScript code block only. You can create local variables. Some logic blocks (such as the for loop block) also create local variables.
To create a new local variable, click the green + icon, specify the variable type, Variable Name, and Initial Value. You can also set the Block Color.
Tip: You can use block colors to group logic blocks visually in the workspace.
Search:
•The Search box enables you to find local variables that have names containing the search string.
•To search, type a search string in the Search box, and then press Enter. The list is filtered to show only those that satisfy the search criterion.
•To exit Search mode and view the entire list, click the small x icon beside the Search box.
The central area of the Visual Logic editor is the workspace. This is where you drag in objects (such as parameters, variables, and functions) to create logic blocks, and then link the blocks to establish logical connections between them.
If the segment of ogScript code you are editing has multiple functions, each function appears on a separate tab in the Visual Logic workspace.
Tip: The workspace is usually larger than the available display space. Use the scroll bars on the right and bottom of the workspace to adjust the view.
The Control and APIs panel lists logic blocks associated with logical operations (controls) and API functions (including ogScript functions).
Control:
The Control folder contains logic blocks that perform logical and mathematical operations. You can use these logic blocks to test conditions (if, switch), set up loops (for, while), parse and manipulate string data, and perform mathematical calculations.
ogScript:
The ogScript folder contains ogScript functions that can get/set parameter values, manipulate panel elements, read and write to files, read/write/parse messages, communicate by HTTP, FTP, UDP, and TCP/IP, and more.
For detailed reference information about ogScript functions, see the DashBoard CustomPanel Development Guide (8351DR-007).
API Functions:
The API Functions folder contains functions made available by importing an external API, or by creating an internal API. You can drag these functions into your CustomPanel.
Note: The API Functions folder is visible only if one or more API functions are available.
For more information, see Creating Internal and External APIs.
API Objects:
The API Objects folder contains objects made available by importing an external API, or that are defined in an internal API. You can drag these objects into your CustomPanel.
Note: The API Objects folder is visible only if one or more API objects are available.
local functions:
Local functions are functions created within an ogScript-based item (api, ogscript, task, timertask), and made available only within that item.
The local functions folder is visible only if the ogScript code block contains one or more local function definitions.
To create a new local function, click the click the green + icon, click Add Function, specify the properties of the function (Function Name, Has Return value, # of Arguments), and then click Ok.
By default, there are no tabs in the workspace. If you add a new local function, your existing work appears on the Main tab, and the new function appears on a tab named after the function. Each additional function appears on a separate tab.
Functions you create from the Control and API panel are available only within the current segment of ogScript code. For information about creating functions that are available throughout the current CustomPanel (internal APIs) or available to other panels (external APIs), see Creating Internal and External APIs.
Search:
•The Search box enables you to find logic blocks that have names containing the search string.
•To search, type a search string in the Search box, and then press Enter. The list is filtered to show only logic blocks that satisfy the search criterion.
•To exit Search mode and view the entire list, click the small x icon beside the Search box.
Logic blocks are visual representations of ogScript code segments. Each logic block represents a functional unit, such as a parameter, a local variable, a logical control, or an ogScript function.
To create a working ogScript code segment, you drag multiple logic blocks into the workspace and then link them together to define how they interact.
(Figure 1.3) shows the parts of the if logic block, which compares two input values and executes other logic blocks based on the test results.
Figure 1.3 - The if Logic Block
(Figure 1.4) shows two if logic blocks connected to each other and to other blocks.
Figure 1.4 - The if Logic Block Connected to Other Logic Blocks
In (Figure 1.4), two parameter blocks (orange titles) provide the data to be compared by the if blocks. Text boxes for input 1 and input 2 on the if blocks are not shown, because the input values are provided by parameters.
This example is from a simple number guessing game. Cascading if blocks evaluate whether the user’s guess (ChooseNumber) matches the Secret Number, and either changes the Success parameter value to display a win message (Correct Guess!), or changes the value of the HigherLower parameter to display one of two hints.
The colors of the lines connecting the logic blocks have meanings:
•Red lines with arrowheads indicate the order in which logic block actions are executed.
•Blue lines with arrowheads indicate the sharing of data from one logic block to another.
•If a line is green, it is currently being drawn or moved.
A green dot on the left side of a logic block indicates a data input.
A yellow dot on the right side of a logic block indicates a data output.
Data inputs and outputs appear on almost every type of logic block, including parameter blocks, local variable blocks, math blocks, most control blocks, most device blocks, and all ogScript blocks.
Data can come from parameters, local variables, and math blocks. Some blocks also accept typed input, or provide a drop-down list of valid values.
To share data from one logic block to another, click and drag from a data output point (yellow dot) on one block to a data input point (green dot) on another block. You can share data from one block to multiple other blocks.
It is often important to make one operation occur before another. You can link logic blocks to define their order.
Red arrowheads on the top and bottom of a logic block are connection points. To arrange two blocks in order, click and drag from the bottom connection point of the first block to the top connection point of the second block.
Some blocks have red arrowheads on their right sides. These blocks can execute other blocks. For example, a block that contains a logic test can execute other blocks based on the result of the test. Each possible test result has a connection point. Blocks connected to one of these points may or may not be executed, depending on the result of the logic test.
The title bars of logic blocks are colored, to visually group the blocks. By default, parameter blocks are orange and all other blocks are light blue. When you add a device or create a local variable, you can specify its block color.