Value Tables
- Aktualisiert2025-10-31
- 6 Minute(n) Lesezeit
A value table is a container data type in PAtools. You can use any data type in value tables. You can use a different data type in every row.
The following are true of read and write access in value tables.
- PAscript supports the following data types for read
access:
- Integer: int32
- Floating-point number: real64
- Text: text
- PAscript supports the following data types in cells for read
access:
- Tasks: task
- Events: event
- Step tables: stepTable
- Sequence tables: sequenceTable
- PAbasic: pabasic
- The elements for read access can be constant values or names.
- Type functions allow you to enter text or numbers in the cells. Variables or constants of
the corresponding data type are allowed as transfer parameters. Use the following type
functions for write access:
- setText
- setInt32
- setReal64
- You cannot use the setText type function to write names to a value table.
Type Functions of Value Tables
Use type functions of value tables to TBD.
clear Example
program
variant[2,2] table
table:clear() // after execution the content is [KWE,KWE;KWE,KWE]
endprogram
clearCell Example
program
variant[2,2] table
table:clearCell(0,0)
endprogram
copyFrom Example
program
variant[2,2] target
variant[3] source[1,2,3]
target:copyFrom(source)
endprogram
getCellType Example
program
section globals
variant[] table
end section
int32 row index
for rowIndex = 0,rowIndex<tab:rows -1
switch table:getCellType(rowIndex, 0)
case variant:ce11Type:real64
sys:loginfo(sys:ui,"element is integer")
case variant:ce11Type:int32
sys:loginfo( sys:ui,"element is float") case variant:cellType:text
sys:loginfo(sys:ui,"value is text")
end switch
endfor
endprogram
getColumnLabel Example
program
int32 columnIndex = 0
text columnsText(10)
variant[2,2] table
columnText = table:getColumnLabel(columnIndex)
endprogram
getPageLabel Example
program
int32 pageIndex = 1
text pagesText(10)
variant[2,2,2] table
pageText = table:getPageLabel(pageIndex)
endprogram
getRowLabel Example
program
int32 rowIndex = 1
text linesText(10)
variant[2,2] table
rowText = table:getRowLabel(rowIndex)
endprogram
resize Example
program
text pagesText(10)
int32 status
variant[2,2] table = (1,2;3,4]
status = table:resize(3) //the result is a 1 x 3 field with the content [1,2,0]
if status < 0 then
sys:logError(sys:ui,"Error %d while increasing array", status)
endif
endprogram
setColumnLabel Example
program
int32 columnIndex = 1
text columnsText(20) = "Label Column 2"
variant[2,2] table
table:setColumnLabel(columnIndex,columnText)
endprogram
setPageLabel Example
program
int32 pageIndex = 1
text pagesText(20) = "Label Page 2"
variant[2,2,2] table
table:setPageLabel(pageIndex,pageText)
endprogram
setRowLabel Example
program
int32 rowIndex = 1
text linesText(20) = "Label Line 2"
variant[2,2] table
table:setRowLabel(rowIndex,rowText)
endprogram
fromCSV Example
program
int32 status int32[2,2] array
status = array:fromCSV("Field.csv",";") if status < 0 then
sys:logError(sys:ui,"Error %d writing CSV file", status)
endif
endprogram
toCSV Example
program
section globals
variant[] table
end section
int32 status
status = table:toCSV("Field.csv",";")
if status < 0 then
sys:logError(sys:ui,"Error %d writing CSV file", status)
endif
endprogram
Definition Options
Define PAscript value tables locally or globally.
Definition of Value Tables
The following pattern is used to define value tables:
variant[] variable_name
Global Definition of Value Tables
To declare a global value table in PAscript, enter the variant[] data type in a section globals code block. Then, enter the variable name.
Example
program
section globals
variant[] AKS_Parameter.WTB
endsection
...
endprogram
Local Definition of Value Tables
The following pattern is used for defining local value tables:
variant[field dimensions] identifier
Defining Field Dimensions
You can select one, two, or three dimensions for field dimensions.
variant [n] identifier // Value table with n elements variant [n,m] identifier // Value table with n rows and m columns variant [n,m,p] identifier // Value table with p pages, n rows and m columns
The cell content of the created value table is KWE.
Example
program
variant[2,3] table
...
endprogram
Accessing Value Tables
Access an element of a value table using access methods. Access methods assign the data type and have the relevant index for the column, row, and page as transfer parameters.
Rule for Dimension Specification
You can call the access methods by specifying fewer dimensions than are defined for the value table itself.
For example, you define a value table with three dimensions. In this case, there is no need to specify the page index, row index, or column index. You can specify only one index. The value of the first rows on the first page and the transferred column are calculated.
Similarly, you can specify the row and column only. In this case, access is always to the first page.
Referencing Value Tables
The = operator causes the table on the left to reference the table on the right.
The dimensions of the destination adapt to the dimensions of the source.
A subsequent change to the dimension or value in one of the tables changes the dimension or values in the other table.
Example
program variant [2,3] source variant [3,3,2] target // causes redimensioning of the target target = source endprogram
The dimensions of target adapt to the dimensions of source.
A change of source results in an identical change of target. A change of target results in an identical change of source.