The following onNavigate event handler sets the enabled properties of the navigation buttons on a form, based on the return values of atFirst( ) and atLast( ).

function Rowset_onNavigate

   if this.endOfSet 

      return // Do nothing if end-of-set 

   endif 

   local lBackward, lForward 

   lBackward = not this.atFirst( ) 

   lForward = not this.atLast( ) 

   with this.parent.parent 

      buttonFirst.enabled := lBackward 

      buttonPrev.enabled := lBackward 

      buttonNext.enabled := lForward 

      buttonLast.enabled := lForward 

   endwith 

The event handler does nothing if the rowset is at the end-of-set, expecting that the row cursor will be moved in the reverse direction of the navigation. If the navigation attempt was forward, the row cursor would be moved back to the last row, and if the navigation attempt was backward, the row cursor would be moved forward to the first row. In this way, the rowset is never on the end-of-set. This technique cannot be used for rowsets where there may not be any matching rows.