Variant: Value Tables

A value table is a Container data type in PAtools, which means that any data can occur in value tables. A different data type can be used in every row.

  • For the read access PAscript currently supports data types integer (int32), floating-point number (real64) and text.
  • Reading is also possible for cells that contain tasks (task), events (event), step tables (stepTable), sequence tables (sequenceTable) and PAbasic (pabasic).
  • The elements for the read access can be constant values or norm names.
  • For write access, you can use the type functions setText, setInt32 or setReal64 to enter texts or numbers in the cells. Variables or constants of the corresponding data type are allowed as transfer parameters.
  • It is not possible to use the setText type function to write norm names to a value table.

Definition Options

Data Type Global Local
variant

Definition of Value Tables

Definitions of value tables generally follow this pattern:

variant[] variable_name

Global Definition of Value Tables

To declare a global value table in PAscript, enter the variant[] data type in the section globals followed by the variable name.

Example

Local Definition of Value Tables

The definition of local value tables follows this pattern:

variant[Field dimensioning] Variable name

Field Dimensioning

One, two, or three dimensions can be selected for field dimensioning.

variant [n]    Variable name    // Value table with n elements
variant [n] [m]    Variable name    // Value table with n rows and m columns
variant [n] [m]    Variablename    // Value table with p pages, n rows and m columns
Note Initialization of local value tables is currently not implemented.

The cell content of the created value table is KWE.

Example

Access to Value Tables

Access to an element of a value table is obtained by means of access methods, which assign the data type and have the relevant index for column, row and page as transfer parameters.

Notice All indices start at 0 and have as their greatest permitted value < Number of elements of the dimension - 1>.

Rule for Dimension Specification

It is possible to call the access methods by specifying fewer dimensions than are defined for the value table itself. This means that if a value table was defined with three dimensions, there is no need to specify the page index, row index or column index. It is also possible to specify only the column index, for example. In this case the value of the first rows of the first rows of the first page and the transferred column will be calculated. Similarly it is also possible to specify only the row and column. Then access will always be to the first page.

Copying Value Tables

The type function :copyFrom() can be used to copy the content of one field into another value table.

The dimensioning of the destination is adapted to the dimensioning of the source.

A subsequent change to the dimension or value in one of the tables has no effect on the dimension or values in the other table.

The = operator can be used to copy the content from a value table to another value table.

Example

section globals
  varianttargetTable, sourceTable
endsection
sourceTable[0]="Hello"
targetTable:copyFrom(sourceTable)  // targetTable[0] is now also "Hello"

Referencing Value Tables

The = operator causes the table on the left to reference the table on the right.

Here, too, the dimensioning of the destination is adapted to the dimensioning of the source.

A subsequent change to the dimension or value in one of the tables effects that the dimension or values in the other table are also changed.

Example

The dimensions of target is adapted to the dimensions of source.

A change of source results in an identical change of target and vice versa: A change of target results in an identical change of source.