Taking Control of Quitting


Prior to version 4.1 of SiMPLE, whenever you successfully invoked one of the "quit" tasks or functions (such as "Readquitkey", "Waitquitkey", . . . or even "Quit" itself), your program would immediately terminate execution. While this was generally a good thing for most elementary applications, it was bad if your program had any "unfinished business" to attend to (such as closing auxiliary screens, handles, etc.)

Version 4.1 (or later) gives your Ultra-SiMPLE programs the option of redirecting all such "quit" operations to your own block of code (which must be an Int function named "myquit"). From there, you can take care of any "unfinished business", and then invoke the "Goodbye" task to actually end the program.

For example, if your program had opened auxiliary screens 1 and 2, your "myquit" function would probably look something like this:

A Typical "myquit" Listing

To utilize this optional "myquit" feature, all you need do is place an asterisk in the rightmost position of the "Ultra" compiler directive:

Ultra-SiMPLE *


The "myquit" feature is especially useful if your program is running in a window. Because then you can use the window's close button to end execution, just as if you had called the "Quit" task.

For example, try running the following program:

Program Listing

Notice that the program's loop doesn't even need to invoke any of the usual "quit" tasks (such as "Readquitkey").

Summary

To take control of quitting, just remember to do two things:

1 - Place an asterisk in the rightmost position of the "Ultra" compiler directive:

Ultra-SiMPLE [] *

2 - Include an Int function named "myquit" somewhere in your source listing:

Int myquit()
(your code)
Goodbye


To see more examples of how to use "myquit", look at some of the program listings in the "SiMPLE Samples" folder.



  [ Webmaster | FAQ's | Home Page | Contact Us ]