Using Variables in RTView Cloud's RTDraw

Variables allow you to update the data of one or more objects in your display by changing the value of the variable. For example, you can create a variable that points to a specific table and then use that variable in one object to show data for that particular table, as well as count the number of rows and display the totals in a different object. Then, by simply changing the table name in the variable, you can automatically update the data in both objects.

You can create variables by choosing Options > Variables from the RTDraw title/menu bar and defining a variable name and a value. To use the variable, simply use the variable name with a prepended $ (for example, $varName) when attaching to your data or to your functions. See the example below for more information.

Prerequisites

You must have completed the flow in the “/wiki/spaces/ENG/pages/566198273” document.

Using Variables

To demonstrate the benefits of using variables and how to add variables, let’s continue our flow from the “/wiki/spaces/ENG/pages/566198273” document. At this point in the flow, we have added a table object and attached data to it, and added an integer field with a function attached to it. This flow will define a variable that we will attach to both the table attachment and the function so that we can update the data in both the table and the integer field by changing the value of the variable.

  • Click Options > Variables from the RTDraw title/menu bar.

The LOCAL VARIABLES dialog displays.

  • Enter a name (use selectTable) in the field next to the Add+ button, click the Add+ button, and then specify a Value (specify a table name -- we used current in our previous example in the “/wiki/spaces/ENG/pages/566198273” section), and click Ok.

The variable is saved.

  • Right-click inside the table and select Attach to Data > Cache (Advanced) or click on the Data object properties drop down and select Cache (Advanced).

  • Replace the selected table (was current) with the variable name prepended with a $ (for example, $selectTable), and click Ok.

  • Navigate to Options > Functions on the RTDraw title/menu bar.

  • Click the pencil (edit) icon.

A second FUNCTION dialog displays.

  • Click the table drop down and select Cache (Advanced).

The ATTACH TO CACHE_ADVANCED dialog displays.

  • Enter your variable name with a prepended $ ($selectTable) in the table field and click Ok in all dialogs.

  • Navigate to Options > Variables on the RTDraw title/menu bar and change the value of your variable from one table to another table. In our example, two of the tables in the PnSensorNetwork cache were “current” and “history.” We had originally selected current, so change the table name to history and click Ok.

Both the data in the table and the data in the Integer object (Total Row Count) should be updated to reflect the number of rows in the new (history) table.

You can continue switching back and forth between the different tables in the cache.