The following onClick event handler for a button labeled "Apply" tests the rowset’s state property so that it calls either applyFilter( ) or applyLocate( ), depending on the rowset’s current mode. 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.

#define STATE_CLOSED 0

#define STATE_BROWSE 1

#define STATE_EDIT 2

#define STATE_APPEND 3

#define STATE_FILTER 4

#define STATE_LOCATE 5

 

function applyButton_onServerClick( ) // Apply Filter or Locate

   do case 

   case form.rowset.state == STATE_FILTER 

      this.form.rowset.applyLocate( ) 

   case form.rowset.state == STATE_LOCATE 

      this.form.rowset.applyFilter( ) 

   endcase