The following method handles these conditions:

Abandoning changes to an existing row

Abandoning a new row

Choosing to abandon an existing row when there are no changes

Choosing to abandon a new row when there are no changes

Abandoning other rowset modes

It uses manifest constants created with the #define preprocessor directive (and available in the VDBASE.H include file) to represent the options of the state property, which makes the code more readable, and macro-functions to display a simple alert dialog box to display a yes/no dialog box and return true or false.

#define STATE_CLOSED 0

#define STATE_BROWSE 1

#define STATE_EDIT 2

#define STATE_APPEND 3

#define STATE_FILTER 4

#define STATE_LOCATE 5

#define alert(m) (msgbox(m,"Alert",64))

#define confirm(m) (msgbox(m,"Confirm",4+32)==6)

function Rowset_canAbandon

   if this.state == STATE_EDIT 

      if this.modified 

         return confirm( "Abandon changes?" ) 

      else 

         alert( "No changes made; nothing to abandon" ) 

         return false // Do not fire onAbandon 

      endif 

   elseif this.state == STATE_APPEND 

      if this.modified 

         return confirm( "Abandon new entry?" ) 

      else 

         return true // Discard new blank row 

      endif 

   else 

      return true // OK to abandon Filter and Locate modes 

   endif