Global Tables
Overview and Key Concepts
Global Tables can store numbers, strings, pointers, arrays, FlexScript, bundles or tracked variables. This data can be accessed by any object in the model using the Table class interface. A model may have any number of Global Tables.
Global Tables are accessed from the Toolbox.
Getting and Setting Table Data
Here are some code examples of getting and setting table data.
Table myTable = Table("GlobalTable1");
myTable[1][1] = 5;
myTable[2]["MyCol"] = "Test";
item.LabelName = myTable[1][2];
double value = Table("GlobalTable1")[1]["Col 3"];
Editing the Table
To edit a cell in the table, click the desired cell and begin typing to overwrite all data in the cell, or double click on the cell to select the cell's contents. You can also right-click a cell and select Explore As Table or Explore As Tree and edit the cell's data through there. If the cell has array or bundle data, double-clicking the cell will open a new table window for editing.
Use the arrow keys to navigate between cells. Cells hold number data by default. You can change a cell's data type by right-clicking on the cell and selecting an option under the Assign Data menu. The right-click menu also has options for insert/deleting rows and columns, clearing cell data, and sorting by column.
Properties
- Name Combobox - This is the table's name and has a list of all of the model's Global Tables. The name should be memorable and describe the table's function. The commands to read and write to global tables access them by name. You can view other Global Tables in this window by clicking the dropdown arrow next to the name.
- - This button adds the table as a row in the Excel Importer or Excel Exporter.
- - Pins the entire global table to a dashboard as either a table of values, bar chart or line graph.
- - This button lets you add this table to a user library as either a draggable icon or as a component for automatic install.
- Rows - This is the number of rows in the table.
- Columns - This is the number of columns in the table.
- Use Bundle - If this box is checked, the internal data type of the table will be changed to bundles. See the Bundle Data heading below.
- On Reset Trigger - The On Reset trigger gives you the ability to define what happens to the table's data when the model is reset. This could be clearing all cell data, delete all rows, or some other custom defined behavior.
- Description - This text box allows you to document your model by writing a description of the table. Here you can explain the purpose and organization of your table.
Bundle Data
If the "Use Bundles" checkbox is checked, your table will change internally to use the bundle data type. This means that your table will take significantly less memory. However, there are some limitations. All data in a column must be of one type, either number or string, and rows can no longer be named. The data type of a column can be changed by right-clicking in a cell in the column. All of the normal table functions will work with the bundle data type.
Using bundles for your table data is highly recommended for large tables with over 500 rows or columns.
Cell Data Types
Cells in a table can store a variety of different types of data. These include:
- Numbers: Integer or floating point.
- Strings: Text like names or sentences.
- Pointers: References to other nodes or objects. The value displayed is the path to the node/object and will be purple.
- Arrays: Arrays can have any number of elements. Each element can store a number, string, pointer or array.
- FlexScript: FlexScript toggled nodes allow you to write code that
can that be evaluated using the evaluate() method. For example,
Table("GlobalTable1").cell(1, 1).evaluate()
- Bundles: Data table that stores numbers and strings.
- Tracked Variables: Tracked variables are often used for statistic collection.
Additionally, a cell can also store a table of data. This can be done regardless of the data stored on the cell. To create a table on a cell, right click on the desired cell and select Explore As Table. This will open a new table window where you can add rows and columns to the cell. If a cell has a table, a small gray triangle will be drawn in the upper right corner of the cell.
Tracked Variable cells will display with a small green triangle in the upper right corner.
If a cell has array or bundle data, double-clicking on the cell will open a table view that can be edited.