Geosoft GX Developer 8.5

Termination, Error Handling and Progress Feedback

With normal execution of a GX, no explicit termination statement is required. The process proceeds to the last executed statement in the main program block. A number of cases exist, however, perhaps due to errors in execution, unexpected parameter values, or user intervention, when the GX must terminate prematurely. Several functions exist to handle the various scenarios.


 

Exit_SYS Function

The Exit_SYS function is a “soft landing” early exit. Execution ceases as if it were the end of the GX, and no message is written to the user or log file. No error is registered, so if the GX has been called from another GX, the calling GX will proceed normally.

Cancel_SYS Function

Abort_SYS Function

Messages and Warnings to Users

Within interactive sections of the GX it is possible, through careful design, to “trap” bad or missing parameter values, or unusual conditions, and alert the user, without terminating the GX with a call to one of the above three functions. One method is to enclose the interactive portion of the GX within a while(){} statement, and break out of the loop only when all necessary conditions have been met. A DisplayMessage_SYS (or DisplayInt_SYS or DisplayReal_SYS) message can be used to alert the user. Once the user reads the message and selects the “Ok” button, the dialog comes up again so the value can be altered. The following is an example:

Progress Indicators

For processes that may take a long time to complete, it is important to provide feedback to the user about the current state of progress. The Progress_SYS functions are designed to create a progress bar with a message and “Stop” button to allow premature termination of the process. The following example illustrates the various aspects of setting up a progress indicator:

The progress bar shows the percentage of the process which has been completed. To calculate the percentage requires that some progress variable be defined. Often, this is the number of selected lines in a multi-line database. Alternatively, it could be the number of rows in a single line of data.

Turn on the progress indicators. Many Geosoft functions contain their own progress reporting capabilities, which are normally disabled. Calling Progress_SYS(1) activates not only the progress indicators for the current GX, but for the called functions as well.

Set a progress name. This may be done once, or may be changed on each update of the progress indicator. In this case it will be changed with every line. This call, without a name, is used to set the initial indicated percentage to 0.

Update the progress bar within the process loop. The message is changed to reflected the current line, without affecting the displayed percentage. The iCheckStop_SYS function allow the user to break prematurely from the process.

 Finally, after all processing function calls, turn off the progress indicator