One possibility is to use the "
BeforeDeleteInstance" event to execute a script before an instance is deleted. Within the script you can define a query for the user. Thereafter you can use the returned value as an input for the
EXIT command to either stop the execution of the code and thus preventing the deletion of an instance or not.
The code for this purpose would look the following (You place the event in the external coupling of your library):
1ON_EVENT "BeforeDeleteInstance" {
2EXECUTE file: ("db:\\EVENT_before_delete_instance.asc") scope:same
3EXIT(nBeforeDeleteInstanceExit)
4}
In this case the content of the EVENT_before_delete_instance.asc AdoScript file looks the following:
1CC "AdoScript" QUERYBOX "Ary you really sure that you want to delete this object?" yes-no def-no
2# -->RESULT endbutton:strValue
3IF(endbutton = "no") {
4 SET nBeforeDeleteInstanceExit: -1
5} ELSE{
6 SET nBeforeDeleteInstanceExit: 0
7}
Thus,depending on what option the user selects on the querybox the variable “nBeforeDeleteInstanceExit” will hold either -1 or 0. The value serves as a parameter for the EXIT command within the “ON_EVENT” scope. EXIT (0) means that there will be no abortion and the instance will be deleted. EXIT (-1) means that the execution will be aborted without an error and the instance will not be deleted.
See attached an example library with the included event and the corresponding AdoScript file.