Suppose you have a 12-page survey form. There are buttons to move to the next and previous pages. These buttons are on page zero, so that they appear on every page. The Previous button has its visible property initially set to false, because the form starts on page 1 and there is no previous page to go to. When you get to page 12, you want to hide the Next button, since there are no more pages.

The onClick event handlers for the two buttons would look like:

function nextPageButton_onClick( )

   if ++form.pageno >= 12 // Goto next page, and if it's the last page 

      this.visible := false // You can't go any further 

   endif 

   form.prevButton.visible := true // Always make previous button visible 

   

function prevPageButton_onClick( )

   if --form.pageno <= 1 // Goto previous page, and if it's the first page 

      this.visible := false // You can't go any further 

   endif 

   form.nextButton.visible := true // Always make next button visible 

The prefix increment and decrement operators are used so that the page number is changed before it is tested. It’s not necessary to see if you should be allowed to change pages; if the button is visible, you can go in that direction. Finally, going in one direction always makes it possible to go the other way.