Statement EXIT PROCEDURE Foundation
Declares a procedure which is executed at the end of a program.
EXIT PROCEDURE <ProcedureName>
[LOCAL <VarName_L> [ [:= <Expression>],...]]
[MEMVAR <VarName_M,...>]
[FIELD <FieldName,...> [IN <AliasName>]]
<SourceCode>
[RETURN]
The EXIT PROCEDURE statement is used to declare closing procedures that are automatically called before an Xbase++ program has ended and before control returns to the operating system. They are only called when a program terminates by the QUIT command or by the RETURN statement from the main procedure or function of a program. If a program terminates due to a runtime error or after pressing Alt+C, no EXIT PROCEDUREs are executed.
EXIT PROCEDURE routines have no parameters and cannot be explicitly called during program execution. They are only known to the system, which executes a list of EXIT PROCEDURE routines. The order in which the EXIT PROCEDURE routines are called is not predictable. After completion of the last exit procedure, control returns to the operating system. If a runtime error occurs within an exit procedure, the program immediately terminates.
With the ANNOUNCE statement, a symbol can be declared. In order to link existing EXIT PROCEDURE routines to a new application, the corresponding program module must be explicitly requested with REQUEST.
// The example shows INIT and EXIT procedures being used to time the
// running of a program. The INIT procedure records the start time and
// the EXIT procedure records the end time.
ANNOUNCE Logbook
INIT PROCEDURE LogIn()
USE Login NEW
APPEND BLANK
REPLACE Login WITH .T. , ;
REPLACE LogDate WITH Date() , ;
LogTime WITH Time()
USE
RETURN
EXIT PROCEDURE LogOut()
USE Login NEW
APPEND BLANK
REPLACE Login WITH .F. , ;
REPLACE LogDate WITH Date() , ;
LogTime WITH Time()
USE
RETURN
PROCEDURE Main
LOCAL nMenuItem
DO WHILE .T. // Continuous loop
CLS
@ 2, 1 PROMPT " DBF file "
@ 4, 1 PROMPT " NTX file "
@ 6, 1 PROMPT " Search "
@ 8, 1 PROMPT " Quit "
MENU TO nMenuItem
SetPos( 0, 0 )
DO CASE
CASE nMenuItem == 1
? "Select DBF file"
CASE nMenuItem == 2
? "Select index file"
CASE nMenuItem == 3
? "Search data record"
CASE nMenuItem == 4
QUIT // Exits program
ENDCASE
? "Press a key..."
Inkey(0) // Wait...
ENDDO
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.