AFTER DELETE block
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.
AFTER DELETE
is
executed for the delete row, and DIALOG.getCurrentRow()
/
arr_curr()
will be one greater than
DIALOG.getArrayLength()
/ ARR_COUNT()
. Ensure
you avoid accessing a dynamic array with a row index that is greater than the total
number of rows, otherwise the runtime system will adapt the total number of rows to
the actual number of rows in the program array. When using a static array, you must
ignore the values in the rows after ARR_COUNT()
.Here the AFTER DELETE
block is used to re-number the rows with a new item line
number (note that DIALOG.getArrayLength()
/ ARR_COUNT()
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.