Description
A class that represents a table structure.
A Table contains methods and properties associated with manipulating table
data in FlexSim. A Table may be one of the following:
- A Tree Table: This is a table whose data is defined in the tree structure. This
consists of a root node with one or more subnodes, each representing a row in the table. Subnodes
of each row represent cells in the table.
- A Bundle Table: This is a table whose data is defined by a bundle node. This
consists of a node in the tree that contains bundle data.
- A Query Result Table: This is a read-only in-memory table that contains the result
of a call to Table.query().
Bundle and tree tables can be stored anywhere in the model tree. Often they are stored as global tables,
or on object labels.
Properties
numCols |
The number of columns in the table. |
numRows |
The number of rows in the table. |
Methods
addCol |
Adds a column to the table. |
addRow |
Adds a row to the table. |
cell |
Returns a specific table cell. |
clear |
Sets all cells to empty values. |
clone |
Creates an array copy of the table. |
cloneTo |
Copies all values from this table to the target table, returning the target table. |
deleteCol |
Deletes a table column. |
deleteRow |
Deletes a table row. |
executeCell |
Executes the text on the cell as FlexScript. |
getColHeader |
Gets a table column header. |
getRowHeader |
Gets a table row header. |
moveCol |
Moves a column to a new index. |
moveRow |
Moves a row to a new index. |
setColHeader |
Renames a column header. |
setRowHeader |
Renames a row header. |
setSize |
Resizes the table. |
sort |
Sorts table columns. |
swapCols |
Swaps indexes of the two columns. |
swapRows |
Swaps indexes of the two rows. |
Constructor
Table |
Creates a reference to a global table. |
Static Methods
query |
Executes an SQL query, returning the result as a Table. |
Operators
[] |
Gets or sets the value of a table cell. |
= |
Assigns a reference to a treenode to the Table object. |
Details
Do no remove, this fixes the anchor on doc.flexsim.com
readonly int numCols
Description
The number of columns in the table.
int columns = table.numCols;
For bundles it is the number of fields.
Do no remove, this fixes the anchor on doc.flexsim.com
readonly int numRows
Description
The number of rows in the table.
int rows = table.numRows;
For bundles it is the number of entries.
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
col |
The index at which to insert the column. |
datatype |
The datatype of the new column. |
Returns
Description
Adds a column to the table.
table.addCol(2);
If no column index is specified the column will be added at the end.
If no datatype is specified the new column will copy the datatype of the previous column.
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
row |
The index at which to insert the row. |
datatype |
The datatype of the new row. |
Returns
Description
Adds a row to the table.
table.addRow(2);
If no row index is specified the row will be added at the end.
If no datatype is specified the cells will copy the datatype of the cells in the previous row.
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
row |
The row index. |
col |
The column index. |
Returns
Description
Returns a specific table cell.
table.cell(2,"Row 3").value = 4;
This will throw an exception for bundles.
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
recursive |
If set to 1, clear will be called on cells with bundle data, array data and on cells that have node tables. |
Returns
Description
Sets all cells to empty values.
table.clear();
table.clear(1);
Number cells will be set to 0, string cells to an empty string, and pointer cells will be set to a null pointer.
Do no remove, this fixes the anchor on doc.flexsim.com
Returns
Array
|
A copy of the table in an array. |
Description
Creates an array copy of the table.
Array myArray = Table("Parts").clone();
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
target |
The target table. This must be a tree-bound table, such as a bundle or tree table. |
Returns
Table
|
The resulting table. This is the same table as the target. |
Description
Copies all values from this table to the target table, returning the target table.
Table.query("SELECT * FROM Customers ORDER BY Name").cloneTo(Table("QueryDump"));
Do no remove, this fixes the anchor on doc.flexsim.com
Table.deleteCol()
Parameters
col |
The index of the column to delete. |
Returns
Description
Deletes a table column.
table.deleteCol(3);
Will throw an exception if no column is specified or the column doesn't exist.
Do no remove, this fixes the anchor on doc.flexsim.com
Table.deleteRow()
Parameters
row |
The index of the row to delete. |
Returns
Description
Deletes a table row.
table.deleteRow(3);
Will throw an exception if no row is specified or the row doesn't exist.
Do no remove, this fixes the anchor on doc.flexsim.com
Table.executeCell()
Parameters
row |
The row index. |
col |
The column index. |
Returns
Variant
|
The return value of the executed function. |
Description
Executes the text on the cell as FlexScript.
Variant result = table.executeCell(2, "Row 3");
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
col |
The index of the column to move. |
newCol |
The index where the column will be moved. |
Returns
Description
Moves a column to a new index.
table.moveCol(2, 5);
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
row |
The index of the row to move. |
newRow |
The index where the row will be moved. |
Returns
Description
Moves a row to a new index.
table.moveRow(2, 5);
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
rows |
The new number of rows. |
cols |
The new number of columns. |
datatype |
The datatype of new cells. |
overwrite |
If old cells should have their values reset. |
Returns
Description
Resizes the table.
table.setSize(5, 3);
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
columns |
The column or columns to sort. |
sortDirections |
The directions each column should be sorted. 0 is Descending and 1 is Ascending. |
Returns
Description
Sorts table columns.
table.sort(1);
table.sort([1, 2, 3], [1, 0, 1]);
Do no remove, this fixes the anchor on doc.flexsim.com
Table.swapCols()
Parameters
col |
The index of the first column. |
col2 |
The index of the ssecond column. |
Returns
Description
Swaps indexes of the two columns.
table.swapCols(2, 4);
Do no remove, this fixes the anchor on doc.flexsim.com
Table.swapRows()
Parameters
row |
The index of the first row. |
row2 |
The index of the second row. |
Returns
Description
Swaps indexes of the two rows.
table.swapRows(2, 4);
Do no remove, this fixes the anchor on doc.flexsim.com
Table Constructor
Parameters
name |
The name of the global table. |
Description
Creates a reference to a global table.
Table parts = Table("Parts");
int numParts = Table("Parts")[3][4];
Do no remove, this fixes the anchor on doc.flexsim.com
Parameters
queryStr |
The sql query. |
p1-p9 |
Only used if you include $ syntax in the query. This defines additional, dynamically
evaluated parameters associated with the query. The value is a "lambda", a type that simply signifies that the parameter
is evaluated as-needed, not immediately when the method is called. You will usually either pass a reference to a
table node here, defining the table to query, or you will use the $iter() command in a FlexScript expression to
dynamically determine the value of a cell in a "virtual table." If this parameter defines a table, it must
be a tree-bound table or a direct reference to a node. In other words, it cannot
be the result Table of another call to Table.query(), unless you clone that result to a tree-bound table with
Table.cloneTo().
See Sql Query Examples for more information. |
Returns
Table
|
The resulting table. This is a read-only in-memory table (it is not stored on a node in the tree). Use
Table.cloneTo() to copy the result to a tree-bound
table. |
Description
Executes an SQL query, returning the result as a Table.
Table result = Table.query("SELECT * FROM Customers ORDER BY Name");
See Sql Query Examples for more information.
Do no remove, this fixes the anchor on doc.flexsim.com
Table.operator []
Parameters
index |
The index or name of a row or column. |
Returns
Variant
|
The variant held by the table cell. If the cell is a FlexScript node this returns the result of executing the code. |
Description
Gets or sets the value of a table cell.
Variant value = table[2]["Orders"];
table[2]["Orders"] = 5;
Do no remove, this fixes the anchor on doc.flexsim.com
Table.operator =
Parameters
node |
The node holding a table. |
Returns
Description
Assigns a reference to a treenode to the Table object.
Table table = reftable(1);