Using the Tag Table Genie
- Last UpdatedJul 18, 2023
- 4 minute read
Use the Tag Table Genie on a page when you want to be able to view variable tags where the value of each tag changes constantly within your project.
The table does not automatically populate with variable tags unless a Cicode function is called to add the tags to it. The Cicode function you use to add a variable tag to the table is:
LibTagTable_AddTag(STRING sTable, STRING sTag, STRING sName = "", STRING sFormat = "", STRING sFormatActive = "", INT iArrayIndex = 0)
Where:
-
sTable = the name of the Tag Table Genie where values will be inserted (required)
-
sTag = the actual tag itself (required)
-
sName = the name of the tag (optional)
-
sFormat = A replacement value to insert into the table if the tag’s value is empty or equal to zero (and sFormat and sFormatActive are both not empty). For example, "bad tag". (optional)
-
sFormatActive = A replacement value to insert into the table if the tag value is not empty or not equal to zero (and sFormat and sFormatActive are both not empty). For example, "good tag". (optional)
-
iArrayIndex = The index of the element in the tag to insert the value for if an array tag is provided in the sTag parameter (optional)
For example:
LibTagTable_AddTag("TestTable", "ModnetIntArray[1]", "ModnetIntArray[1]", "Array","",1)
Example 1
Populating the table with a button
-
From the Object toolbox select -> The Paste Genie icon.
-
In the Paste Genie window select the lib_controls library.
-
Select the Tag Table genie. The tag Table genie is pasted onto the graphics page.
-
In the Tag Table Genie properties dialog, configure the fields according to the table below. Click OK to save the changes.
Parameter
Description
TagTable Name
Tags
Width
300 ( all columns within the table are displayed. If left at 100 the value column is not displayed)
Number of rows
20
Header Height
18
Row Height
15
Header Padding
5
Row Padding
4
Column Padding
5
Horizontal Scrollbar
Vertical Scrollbar
Verbar (name of horizontal scroll bar placed on current page)
Paste the Vertical Scrollbar genie onto the graphics page.
-
Position where the width of the table might end. In the 'Library_Control - Scrollbar' dialog:
-
Scrollbar Name: Verbar
-
Height: 100
-
Update on Drag: True (default)
-
Allow double-click: True (default)
-
Auto Hide: False (default)
-
Hidden When: False (default)
-
-
Click OK to save the changes
-
From the Object toolbox select the 'Button'object
-
Draw a button onto the page and configure as follows:
-
Action: Up
-
Up Command: LibTagTable_AddTag("VariableTags","Bit_1")
-
-
Click OK to save the changes
-
Compile and Run the project.
-
At runtime open the example page and click on the 'VariableTag' button
-
The table will refresh and the Bit_1 tag and corresponding value will be displayed.
Variations of the example include:
-
Adding a second button for another Tag e.g Bit_2
-
Configuring the button to accept multiple tags( though space is limited). The Cicode for the up command could be :
LibTagTable_AddTag("VariableTags","Bit_1");
LibTagTable_AddTag("VariableTags","Bit_2");
LibTagTable_AddTag("VariableTags","Bit_4") -
Configuring a button to launch a form field where you can enter the name of the tag: The Cicode for the up command could be:
LibTagTable_AddTag("Variabletags", Input("Add Tag","Tag name:", ""));
Example 2:
Initialized Cicode function in table configuration
Using the Cicode sample below, open the Cicode Editor and create a function.
Example: 'MyTagTableInitialze' initialization function:
INT FUNCTION MyTagTableInitialize(STRING sTable)
INT hSession;
STRING sCluster;
STRING sTag;
INT nError;
// Add all variable tags to the tag table
hSession = TagBrowseOpen("", "Cluster,Tag", "Cluster:A,Tag:A", "");
nError = TagBrowseFirst(hSession);
WHILE (nError = 0) DO
sCluster = TagBrowseGetField(hSession, "Cluster");
sTag = TagBrowseGetField(hSession, "Tag");
LibTagTable_AddTag(sTable, sCluster + "." + sTag);
nError = TagBrowseNext(hSession);
END
IsError();
TagBrowseClose(hSession);
// Tell the tag table initialization is
RETURN TRUE;
END
As in example 1, add the Tag Table Genie and Vertical scroll bar to the graphics page.
In the Tag Table Genie property dialog, configure the following fields:
|
Parameter |
Description |
|---|---|
|
TagTable Name |
Tags |
|
Width |
300 ( all columns within the table are displayed. If left at 100 the value column is not displayed) |
|
Number of rows |
20 |
|
Header Height |
18 |
|
Row Height |
15 |
|
Header Padding |
5 |
|
Row Padding |
4 |
|
Column Padding |
5 |
|
Horizontal Scrollbar |
|
|
Vertical Scrollbar |
Verbar (name of horizontal scroll bar placed on current page) |
|
Initialze |
MyTagTableInitialize("#Name") |
Paste the Vertical Scrollbar genie onto the graphics page. Position where the width of the table might end.
In the 'Library_Control - Scrollbar' dialog, configure the following fields.
|
Parameter |
Description |
|---|---|
|
Scrollbar Name |
Verbar |
|
Height |
100 |
|
Update on Drag |
True (default) |
|
Allow double-click |
True (default) |
|
Auto Hide |
False (default) |
|
Hidden When |
False (default) |
Compile and then run the project.
At runtime the table will look like the following:
