PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Using the TableAdd function
  • Principle
  • Code samples
  • Using the TableAddLine function
  • Principle
  • Code samples
  • Using the FileToMemoryTable function
  • Principle
  • Code sample
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Several methods can be used to fill a Table control by programming:
Using the TableAdd function

Principle

TableAdd is used to add a row into a Table control managed by programming. 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 found in the Product file into a Table control:
    sRow is string

    // Clear the table content
    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 the TableAddLine function

Principle

TableAddLine is used to add a row into a Table control managed by programming. 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 found in the Product file into a Table control:
    // Add the PRODUCT file into a table
    sRow is string

    // Clear the table content
    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 found in the Product file into a Table control (column by column):
    <code WL>
    sRow is string
    nAddedRowNum is int

    // Clear the table content
    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 is used to fill a Table control managed by programming from a data file (or from an SQL query) in a single operation (without performing any fill 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 sample

TableDeleteAll(TABLE_Product)
FileToMemoryTable(TABLE_PRODUCT, Product)
Minimum required version
  • 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
Jul. 07 2017