This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
WP Table insert rows

WP Table insert rows 


 

WP Table insert rows ( targetObj | {tableRef ; rowNumber} {; numRows} ) -> Function result 
Parameter Type   Description
targetObj  Object in Range or element or 4D Write Pro document
tableRef  Object in Table reference
rowNumber  Longint in Row index number
numRows  Longint in Number of rows to insert (default value = 1)
Function result  Object in Range of table rows

The WP Table insert rows command inserts one or several row(s) into a 4D Write Pro table.

This command supports two syntaxes:

  • If you pass a targetObj as the first parameter, the command will insert the row(s) in the first table intersecting the target. targetObj can contain: 
    • a range, or
    • an element (row / paragraph / body / header / footer / inline picture / section / subsection), or 
    • a 4D Write Pro document. 

      If targetObj does not intersect with a table or text range where rows can be inserted, the command does nothing and returns Null (no error is generated). 
  • If you pass both a tableRef and a rowNumber as parameters, the command will insert the row(s) in the designated table and at the specified row index. If the rowNumber is higher than the number of rows in tableRef, the rows are appended to the table rather than inserted.

The optional numRows parameter defines the number of rows to insert into targetObj or tableRef. By default, if this parameter is omitted, one row is inserted.

 

Result

The command returns a row range representing inserted row(s), or Null if nothing was inserted. 

Example  

You want to insert two rows at the end of the Invoice table:  

 C_OBJECT($row)
 C_OBJECT($table;$row)
 C_LONGINT($rowNum)
 
 $table:=WP Get element by ID(WParea;"Invoice") //retrieve "Invoice" table
 
 If($table#Null)
    $rowNum:=$table.rowCount+1 //add 1 to last row to designate where to insert rows
    $row:=WP Table insert rows($table;$rowNum;2)
 End if

 

will insert the two new rows at the correct location:

 



See also 

WP Table insert columns

 
PROPERTIES 

Product: 4D
Theme: 4D Write Pro Language
Number: 1691

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v18

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v20 R7)