|
|
|
|
|
- Using the TableAdd function
- Principle
- Code samples
- Using TableAddLine
- Principle
- Code samples
- Using the FileToMemoryTable function
- Principle
- Code example
How to populate a Table control programmatically?
Several methods can be used to populate a Table control programmatically: Using the TableAdd function Principle TableAdd is used to add a row to a Table control managed programmatically. To add the row, you must: - Declare a variable to prepare the row to add.
- Concatenate each column value in this variable. Each value is separated by a TAB character. The row to add must have the following format:
Row = <Value Column 1> + TAB + <Value Column 2> + TAB + ... + TAB + <Value Column N> - Add the row with TableAdd.
Code samples - Add a simple row:
sRow is string
sRow = Today() + TAB + TimeSys() + TAB + "my message..."
TableAdd(TABLE_messages, sRow)
- Adding the records from the Product file to a Table control:
sRow is string
TableDeleteAll(TABLE_Products)
FOR EACH PRODUCT
sRow = Product.Reference + TAB + Product.ProdCap + TAB + Product.Price
TableAdd(TABLE_Products, sRow)
END
Info("There are " + TableCount(TABLE_Products) + " added products.")
Principle TableAddLine is used to add a row to a Table control managed programmatically. The only difference with the previous method (using TableAdd) is a syntax difference. Code samples - Add a simple row:
TableAddLine(TABLE_messages, Today(), TimeSys(), "my message...")
- Adding the records from the Product file to a Table control:
sRow is string
TableDeleteAll(TABLE_Products)
FOR EACH PRODUCT
TableAddLine(TABLE_Products, Product.Reference, Product.ProdCap, Product.Price)
END
Info("There are " + TableCount(TABLE_Products) + " added products.")
- Adding the records from the Product file to a Table control (column by column):
<code WL>
sRow is string
nAddedRowNum is int
TableDeleteAll(TABLE_Products)
FOR EACH PRODUCT
nAddedRowNum = TableAddLine(TABLE_Products)
TABLE_Products.Col_Ref[nAddedRowNum] = Product.Reference
TABLE_Products.Col_Cap[nAddedRowNum] = Product.ProdCap
TABLE_Products.Col_Price[nAddedRowNum] = Product.Price
END
Info("There are " + TableCount(TABLE_Products) + " added products.")
Using the FileToMemoryTable function Principle FileToMemoryTable populates a Table control managed programmatically from a data file (or from an SQL query) in a single operation (without using a loop). However, the structure of the Table control (format and order of the columns) must correspond to the format of the file or SQL query. Item 1 in the file or SQL query will be associated with column 1, item 2 will be associated with column 2, etc. Code example FileToMemoryTable(TABLE_PRODUCT, Product)
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|