4D Write Pro R4 (How to insert a table between 2-existing tables?)

GIVEN

  1. 2-tables created one after the other: “A”, “B”.
  2. A reference available to each table.
  3. An empty string separates each-table.

<code 4D>
$range_o:=WP Create range(wpArea_o;wk end text;wk end text)
WP SET TEXT($range_o;"";wk append;wk include in range)
$tableA_o:=WP Insert table($range_o;wk append;wk include in range;3;1)

$range_o:=WP Create range(wpArea_o;wk end text;wk end text)
WP SET TEXT($range_o;"";wk append;wk include in range)
$tableB_o:=WP Insert table($range_o;wk append;wk include in range;3;1)
</code 4D>

QUESTION

How can I insert a table between the existing 2-tables “A” and “B”?

Hello Jeremy,

The answer is in the functions WP Get element by ID or WP Get elements that are really usefull

<code 4D>
C_COLLECTION($tables)
C_OBJECT(wpArea)
C_OBJECT($range;$table;$row)

wpArea:=WP New

$range:=WP Text range(wpArea;wk end text;wk end text)
$table:=WP Insert table($range;wk append;wk include in range)
$row:=WP Table append row($table;“Alpha”;Current date;Current time)

$range:=WP Text range(wpArea;wk end text;wk end text)
$table:=WP Insert table($range;wk append;wk include in range)
$row:=WP Table append row($table;“Bravo”;Current date;Current time)

// Select the first table by its ID if you know it (by default “t1”)

$table:=WP Get element by ID(wpArea;“t1”)
$range:=WP Text range($table;wk end text;wk end text)

// OR (if you don’t know the ID of the first table

$tables:=WP Get elements(wpArea;wk type table)
$range:=WP Text range($tables[0];wk end text;wk end text)

// THEN insert the new table

$table:=WP Insert table($range;wk append;wk include in range)
$row:=WP Table append row($table;“Charlie”;Current date;Current time)

</code 4D>

Note that WP Create range has been renamed WP Text range in v17R5

Hope this helps !

Regards

Roland Lannuzel

: Roland LANNUZEL

Note that WP Create range has been renamed WP Text range in v17R5

Could you please make the change in all the documentation too :pray:
All the examples are still with the old command name :frowning: