Scripts - Table commands
In a MedCalc script, a table is like a matrix but, unlike matrices, tables can contain text and allow formatting.
Tables are primarily used for representation of data and results.
Table
Table(tname) creates a table with name tname in memory.
AppendRow
AppendRow(tname,vcol1,vcol2,...) appends a row with column values vcol1, vcol2, etc., to the table with name tname.
AppendRow(tname,matrix) appends the values of a matrix at the bottom of the table with name tname.
Table(a); AppendRow(a,"Var","Mean"); AppendRow(a,"Weight",72.1); AppendRow(a,"Height",1.68); Print(a);
results in :
Var | Mean |
Weight | 72.1 |
Height | 1.68 |
PrependRow
PrependRow(tname,vcol1,vcol2,...) inserts a row with column values vcol1, vcol2, etc., at the top of the table with name tname.
PrependRow(tname,matrix) inserts the values of a matrix at the top of the table with name tname.
AppendColumn
AppendColumn(tname,vrow1,vrow2,...) adds a column with row values vrow1, vrow2, etc., at the right side of the table with name tname.
AppendColumn(tname,matrix) adds the values of a matrix at the right side of the table with name tname.
PrependColumn
PrependColumn(tname,vrow1,vrow2,...) inserts a column with row values vrow1, vrow2, etc., at the left side of the table with name tname.
PrependColumn(tname,matrix) inserts the values of a matrix at the left side of the table with name tname.
FormatTable
FormatTable(tname,formatstring) sets the default format for the whole table.
The formatstring is a string literal which can contain the following:
- A number; that is the number of decimals used for representing numbers.
- The words "BOLD" or "NORMAL" for bold or normal font weight.
- The words "SHADED" or "CLEAR" for shaded or transparent background.
- Any of the following color names for the text color:
Name Color Name Color White Lime Silver Green Gray Aqua Black Teal Red Blue Maroon Navy Yellow Fuchsia Olive Purple
For example:
Table(a); AppendRow(a,"Var","Mean"); AppendRow(a,"Weight",72.1); AppendRow(a,"Height",1.68); FormatTable(a,"blue 2"); Print(a);
FormatTableCell
FormatTableCell(tname,row,column,formatstring) formats a table cell. See FormatTable above for format encoding.
FormatTableColumn
FormatTableColumn(tname,column,formatstring) formats a table column. See FormatTable above for format encoding.
FormatTableRow
FormatTableRow(tname,row,formatstring) formats a table row. See FormatTable above for format encoding.
Table format precedence
When formats are specified for a cell, its row or column, or the table, the cell format takes precedence over the other formats, in the following order:
- Cell format
- Row format
- Column format
- Table format