A question that has come up more than once about the progress dialogs in our free FileMaker plugin is how to work with the cancel buttons.


Showing or Hiding the button

The cancel button is optional, and appears based on the status of the “Allow User Abort” state. When this is Off, the button won’t appear and when Abort is allowed, then the button appears. So you can control the visibility of this within your script by altering the state.

Trapping for Cancel button clicks

When the cancel button is clicked, it closes the dialog, but you then need to capture that state. Presumably you’re doing some looping script, or a long process with lots of steps. Either each time it loops or at some point in the loop, you’re calling the BE_ProgressDialog_Update function to update the progress.

When the Update function call is successful, the BE_GetLastError function will return 0. When the user has clicked the cancel button, the BE_GetLastError function will return 1 which is equivalent to the FileMaker “User canceled action” error code. Trapping for this in your code allows you to gracefully exit your loop and react to the cancel.