DEFER INTERRUPT and the int_flag
If the user selects Cancel during the CONSTRUCT
,
the built-in global integer variable int_flag
is automatically set to
TRUE
.
Once
int_flag
is set to TRUE
, your program must reset it to
FALSE
to detect a new cancellation. You typically set int_flag
to
FALSE
before you start a dialog instruction, and you test it just after (or in the
AFTER CONSTRUCT
/ AFTER INPUT
block) to detect if the dialog was
canceled:LET int_flag = FALSE
CONSTRUCT BY NAME where_part
...
END CONSTRUCT
IF int_flag = TRUE THEN
...
END IF
The statement DEFER INTERRUPT
in your MAIN
program block will
prevent your program from terminating abruptly if a SIGINT
signal is received.
When using a GUI interface, the user can generate an interrupt signal if you have an action view
named 'interrupt' (the predefined interrupt action). If an interrupt event is received,
TRUE
is assigned to int_flag
.
It is up to the programmer to manage the interruption event (stop or continue with the program),
by testing the value of int_flag
variable.