The simplest dialog box displays a message only, for example:

calculate avg( SALARY ) to nAvgSalary

msgbox( "The average salary is $" + ltrim( str( nAvgSalary, 10, 2 )), "Results")

With only one OK button, you don’t care what the return value from MSGBOX( ) is. You can put an icon in the dialog box to dress it up:

msgbox( "The average salary is $" + ltrim( str( nAvgSalary, 10, 2 )), "Results", 64 )

This example shows a dialog asking for confirmation before proceeding:

function revertButton_onClick

   if msgbox( "Undo changes to this record?", "Revert", 4) == 6 

      form.rowset.abandon( ) 

   endif 

In addition to adding an icon to the confirmation dialog, in this case you probably want "No", the second pushbutton, to be the default. You can also make your code easier to write and more readable by creating manifest constants for the various return values:

#define BUTTON_OK 1

#define BUTTON_CANCEL 2

#define BUTTON_ABORT 3

#define BUTTON_RETRY 4

#define BUTTON_IGNORE 5

#define BUTTON_YES 6

#define BUTTON_NO 7

These manifest constants would be defined in a standard include file, and included in the Header of the form. You could then use them in any of the methods of the form. With these three enhancements, the IF statement would look like:

if msgbox( "Undo changes to this record?", "Revert", 4+48+256 ) == BUTTON_YES 

While you could do the math in advance (4 + 48 + 256 = 308), dBASE Plus is perfectly capable of doing it at runtime with no noticeable delay. In fact, you could extend this idea by using the preprocessor to create standard MSGBOX( ) combinations, for example:

#define CONFIRM(m,t) (msgbox(m,t,4+32)==BUTTON_YES)

This combines the dialog box options and the test to see if the Yes button was clicked. Then in your programs, you would use the CONFIRM( ) macro like a function that returns a logical value:

if CONFIRM( "This record will be lost forever! You sure?", "Delete" )