PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Using the TableAdd function
  • Principle
  • Code samples
  • Using TableAddLine
  • Principle
  • Code samples
  • Using the FileToMemoryTable function
  • Principle
  • Code example
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
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:
  1. Declare a variable to prepare the row to add.
  2. 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>
  3. Add the row with TableAdd.

Code samples

  • Adding 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
     
    // Clear the contents of the Table control
    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.")
Using TableAddLine

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

  • Adding a simple row:
    // Add a simple row
    TableAddLine(TABLE_messages, Today(), TimeSys(), "my message...")
  • Adding the records from the Product file to a Table control:
    // Add the PRODUCT file to a Table control
    sRow is string
     
    // Clear the contents of the Table control
    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
     
    // Clear the contents of the Table control
    TableDeleteAll(TABLE_Products)
     
    FOR EACH PRODUCT
    // Add an empty row
    nAddedRowNum = TableAddLine(TABLE_Products)
     
    // Modify the columns separately
    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 of columns and order of columns) must exactly correspond to the format of the file or SQL query: the item 1 of the file or SQL query will be associated with column 1, then the item 2 of the file or SQL query will be associated with column 2, etc.

Code example

FileToMemoryTable(TABLE_PRODUCT, Product)
Minimum version required
  • Version 9
This page is also available for…
Comments
Another easier way of filling a table column by column from a qry
// Clear the table content
TableDeleteAll(MyTable)

IF HexecuteQry(Qry_New,HqueryDefault) = True Then
FOR EACH Qry_New
TableAddLine(MyTable,Qry_New.Col1,...
TableAddLine(MyTable,Qry_New.Col2,...
TableAddLine(MyTable,Qry_New.Col3,...
TableAddLine(MyTable,Qry_New.Col4,...
TableAddLine(MyTable,Qry_New.Col5)
END
END

Info("There are " + MyTable..occurrence + " added products.")
Diego Sanchez
07 Jul. 2017