You already know that 4D Write Pro allows you to create tables and append rows to them. With 4D v18, we’ve got more thrilling news! We’re excited to announce that managing the insertion and deletion of rows and columns is not only possible, it’s also very easy. This can be done either by programming, thanks to four new commands, or by using the interface (via the widgets or the contextual menu). Keep reading for more details!
4DWP: insertion and deletion of rows and columns
Four new commands to manage rows and columns
In order to insert rows and columns, two new commands have been created: WP Table inserts rows and WP Table insert columns. Both commands return ranges that correspond to parts created inside the table. Following the same logic, two complementary commands have been created to remove rows and columns: WP TABLE DELETE ROWS and WP TABLE DELETE COLUMNS. I’m sure you’ve figured out what they do!
//To insert 2 rows starting at line 3
$row:=WP Table insert rows(WPtable;3;2)
//To delete the second column:
WP TABLE DELETE COLUMNS(WPtable;2;1)
The WP Table get rows, WP Table get columns and WP Table get cells commands have been improved too!
They can still be used to create ranges inside a table as before:
$row:=WP Table get rows($table;3;2)
Now, they can also be used to get information about ranges belonging (or not) to a table. All of these commands can now receive a range as a parameter and will return an object containing useful information such as:
- .firstRow and .rowCount (when using WP Table get rows)
- .firstColumn and .columnCount (when using WP Table get columns)
- .firstRow, .rowCount, .firstColumn and .columnCount (when using WP Table get cells)
For example, let’s say you want to display information about selected cells, here’s the way to go:
$userSelection:=WP Selection range(WParea)
$cells:=WP Table get cells($userSelection)
Automatic actions are also available to insert or delete rows and columns according to current selections in a table: