PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN

  • Using the TableAdd function
  • Principle
  • Code samples
  • Using the TableAddLine function
  • 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 into a Table control managed through 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 through 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 populate a Table control managed programmatically 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 example

FileToMemoryTable(TABLE_PRODUCT, Product)
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment