Usage / DIALOG control blocks |
The AFTER DELETE block is executed each time the user deletes a row of an INPUT ARRAY list, after the row has been deleted from the list.
The AFTER DELETE block is executed after the BEFORE DELETE block and before the AFTER ROW block for the deleted row and the BEFORE ROW block of the new current row.
When an AFTER DELETE block executes, the program array has already been modified; the deleted row no longer exists in the array (except in the special case when deleting the last row). The ARR_CURR() function or the ui.Dialog.getCurrentRow() method returns the same index as in BEFORE ROW, but it is the index of the new current row. The AFTER ROW block is also executed just after the AFTER DELETE block.
Here the AFTER DELETE block is used to re-number the rows with a new item line number (note that DIALOG.getArrayLength() may return zero):
INPUT ARRAY p_items FROM s_items.* AFTER DELETE LET r = DIALOG.getCurrentRow("s_items") FOR i=r TO DIALOG.getArrayLength("s_items") LET p_items[i].item_lineno = i END FOR ...
It is not possible to use the CANCEL DELETE instruction in an AFTER DELETE block. At this time it is too late to cancel row deletion, as the data row no longer exists in the program array.