On Exit question
#36
(06-04-2023, 11:59 PM)NasaCow Wrote:
(06-04-2023, 05:38 PM)TempodiBasic Wrote: @NasaCow

on wikipage of _EXIT you find these instructions:
Quote: If a return value is not 0 the program can handle an exit request at a more convenient time if necessary.
 After being read, the _EXIT value is reset to 0 so store the value when a program delays an exit request.
 Note: Once _EXIT has been used once, you must monitor your program by checking it for user _EXIT requests.
 Don't just use _EXIT once to prevent a user from exiting a program early, as that constitutes bad practice.
....
can you find another way to manage the issue about closing by brute force your program?
Well, that's what I am trying to figure out by copying the wiki example. I was just trying to get it to system out still without doing anything else but it also said you need to an initial _EXIT to enable the use.

(06-04-2023, 08:35 PM)TerryRitchie Wrote:
(06-04-2023, 05:38 PM)TempodiBasic Wrote: @NasaCow

on wikipage of _EXIT you find these instructions:
....
can you find another way to manage the issue about closing by brute force your program?

I just include _EXIT in my checks for the user wanting to leave the program:

Foo = _EXIT

DO
   .
   . <code>
   .
LOOP UNTIL _KEYDOWN(27) OR _EXIT ' ESC pressed or window X clicked
This is actually a great idea, will force run all my normal saving routinues. Does _EXIT in this case retain it value so I can system out afterwards or should I set a flag to retain the value of _EXIT? (Pressing the 'X' multiple times to system out may annoy the user...)
I've never really checked for this. I've always made sure to include an _EXIT check in all my loops where I feel a user may want to leave. I would assume _EXIT contains a testable value only when the X close button is depressed on a window. It would be easy enough to do the following to be sure _EXIT is captured:

Foo = _EXIT
Leave = 0

DO
    .
    IF _EXIT THEN Leave = -1
    .
    . <more code>
    .
LOOP UNTIL _KEYDOWN(27) OR Leave

You could:

DIM SHARED Leave AS INTEGER

somewhere at the top of your code. That way, if you enter another sub/function within the <more code> area that sub/function can set Leave appropriately as well and it will retain the value when sub/function exits. You could even have a check at the beginning of the other subs/functions:

IF Leave THEN EXIT SUB ' or EXIT FUNCTION

that would immediately exit a sub/function if Leave was already previously set. No need to continue further if the user is wanting to exit. Just a few thoughts.
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply


Messages In This Thread
On Exit question - by NasaCow - 06-02-2023, 03:50 AM
RE: On Exit question - by mnrvovrfc - 06-02-2023, 05:29 AM
RE: On Exit question - by NasaCow - 06-02-2023, 06:00 AM
RE: On Exit question - by mnrvovrfc - 06-02-2023, 08:59 AM
RE: On Exit question - by Dimster - 06-02-2023, 11:19 AM
RE: On Exit question - by TerryRitchie - 06-02-2023, 11:27 AM
RE: On Exit question - by Dimster - 06-02-2023, 12:28 PM
RE: On Exit question - by Kernelpanic - 06-02-2023, 01:54 PM
RE: On Exit question - by TerryRitchie - 06-02-2023, 05:33 PM
RE: On Exit question - by bplus - 06-02-2023, 01:28 PM
RE: On Exit question - by bplus - 06-02-2023, 02:21 PM
RE: On Exit question - by Kernelpanic - 06-02-2023, 08:23 PM
RE: On Exit question - by bplus - 06-02-2023, 02:36 PM
RE: On Exit question - by bplus - 06-02-2023, 03:14 PM
RE: On Exit question - by bplus - 06-02-2023, 08:19 PM
RE: On Exit question - by bplus - 06-02-2023, 08:27 PM
RE: On Exit question - by Kernelpanic - 06-02-2023, 08:40 PM
RE: On Exit question - by Dimster - 06-02-2023, 09:33 PM
RE: On Exit question - by mnrvovrfc - 06-02-2023, 09:44 PM
RE: On Exit question - by TerryRitchie - 06-02-2023, 10:52 PM
RE: On Exit question - by bplus - 06-02-2023, 10:59 PM
RE: On Exit question - by TerryRitchie - 06-02-2023, 11:12 PM
RE: On Exit question - by bplus - 06-02-2023, 11:21 PM
RE: On Exit question - by Dimster - 06-03-2023, 01:29 PM
RE: On Exit question - by SMcNeill - 06-03-2023, 01:51 PM
RE: On Exit question - by Dimster - 06-03-2023, 03:10 PM
RE: On Exit question - by TerryRitchie - 06-03-2023, 07:21 PM
RE: On Exit question - by Kernelpanic - 06-03-2023, 03:26 PM
RE: On Exit question - by NasaCow - 06-04-2023, 03:03 AM
RE: On Exit question - by bplus - 06-04-2023, 03:20 PM
RE: On Exit question - by TempodiBasic - 06-04-2023, 04:05 PM
RE: On Exit question - by TempodiBasic - 06-04-2023, 05:38 PM
RE: On Exit question - by TerryRitchie - 06-04-2023, 08:35 PM
RE: On Exit question - by TempodiBasic - 06-04-2023, 10:51 PM
RE: On Exit question - by NasaCow - 06-04-2023, 11:59 PM
RE: On Exit question - by TerryRitchie - 06-05-2023, 12:31 AM
RE: On Exit question - by NasaCow - 06-05-2023, 12:50 AM
RE: On Exit question - by SMcNeill - 06-05-2023, 09:04 PM
RE: On Exit question - by bplus - 06-05-2023, 09:09 PM
RE: On Exit question - by SMcNeill - 06-05-2023, 09:17 PM
RE: On Exit question - by SMcNeill - 06-07-2023, 01:38 AM
RE: On Exit question - by TempodiBasic - 06-07-2023, 09:08 AM
RE: On Exit question - by TempodiBasic - 06-07-2023, 09:31 AM
RE: On Exit question - by NasaCow - 06-08-2023, 12:05 AM
RE: On Exit question - by mnrvovrfc - 06-09-2023, 09:31 PM
RE: On Exit question - by TempodiBasic - 06-09-2023, 09:14 PM
RE: On Exit question - by bplus - 06-10-2023, 05:24 PM
RE: On Exit question - by TempodiBasic - 06-17-2023, 12:18 AM
RE: On Exit question - by bplus - 06-17-2023, 02:29 AM
RE: On Exit question - by GareBear - 06-17-2023, 01:07 AM
RE: On Exit question - by TempodiBasic - 06-22-2023, 12:01 PM
RE: On Exit question - by bplus - 06-22-2023, 12:22 PM
RE: On Exit question - by TempodiBasic - 06-22-2023, 07:45 PM



Users browsing this thread: 18 Guest(s)