Statement INIT PROCEDURE Foundation
Declares a procedure which executes at the start of a program.
INIT PROCEDURE <ProcedureName> [( <Parameters,...> )]
[LOCAL <VarName_L> [ [:= <Expression>],...]]
[MEMVAR <VarName_M,...>]
[FIELD <FieldName,...> [IN <AliasName>]]
<SourceCode>
[RETURN]
INIT PROCEDURE declares start procedures which are automatically called before the main routine of an Xbase++ program takes the control. The parameters supplied on the command line are passed to each procedure declared as an INIT PROCEDURE. If a runtime error occurs during a start procedure, the program is immediately terminated.
INIT PROCEDURE routines cannot be called during program runtime. They are only visible to the startup code that maintains a list of INIT PROCEDURE routines. The order in which INIT PROCEDURE routines are called is not predictable. As soon as an INIT PROCEDURE ends, the next is called. After the last INIT PROCEDURE ends, control passes to the Main function or procedure of an Xbase++ application.
The ANNOUNCE statement declares a symbolic name for the linker. In order to link existing INIT PROCEDURE routines into a new application, the appropriate program module (PRG file) must be explicitly requested with REQUEST.
To follow the program execution of INIT PROCEDUREs in the debugger, it must be started using the command line option "-i".
// 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
? "Selects DBF file"
CASE nMenuItem == 2
? "Selects index file"
CASE nMenuItem == 3
? "Searches data record"
CASE nMenuItem == 4
QUIT // Exits program
ENDCASE
? "Press 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.