Event addline_before
Description
This event is called when an INSERT operation is requested on a (1,N) or (0,N) collection.
Context
In this context, the INSERT operation is not yet done, and the event can reject the creation by returning in ASTATUS
an error status ([V]CST_AERROR
).
The following variables or properties are available in the context:
This
refers to the current Class. All properties can be found using thethis.PROPERTY
syntax.CURPRO
is empty.AEVENT
is equal to ADDLINE_BEFORE.CURPTH
contains the collection code.ALINE
contains the logical line position where the INSERT operation must be done. The different values possible are:[V]CST_ALASTPOS
if a line must be added at the end of the collection.[V]CST_AFIRSTPOS
if a line must be added at the first position of the collection.- any other position between 1 and N (N being the number of lines already present in the collection).
Take care that if you want to control the line that will be shifted (except if it is the last one), you have to use the AGETINDBYLINE
method to get the physical position. This can be done by the following code:
$ADDLINE_BEFORE
Local Integer LCONTROL, POSCONTROL
If ALINE<>[V]CST_ALASTPOS
If ALINE=[V]CST_AFIRST_POS
LCONTROL=1
Else
LCONTROL=ALINE
Endif
POSCONTROL=this.AGETINDBYLINE("COLLECT",LCONTROL)
If POSCONTROL>0
# Here you can control the properties of this.COLLECT(POSCONTROL) to decide if the insertion can be done
Else
# The position sent is not valid, raise an error or ignore
Endif
Else
# The line is added at the end of the collection, perform a control if necessary here
Endif