xHarbour Reference Documentation > Statement Reference xHarbour Developers Network  

INIT PROCEDURE

Declares a procedure to execeute when a program starts.

Syntax

INIT PROCEDURE <procName>
  [FIELD <fieldName,...> [IN <aliasName>]]
 [MEMVAR <var_Dynamic,...>]
  [LOCAL <var_Local> [:= <expression>] ,... ]

       <Statements>

[RETURN]

Arguments

INIT PROCEDURE <procName>
This is the symbolic name of the declared procedure. It must begin with a letter or underscore followed by digits, letters or underscores. The symbolic name can contain up to 63 characters.
FIELD <fieldName>
An optional list of field variables to use within the INIT procedure can be declared with the FIELD statement.
MEMVAR <var_Dynamic>
If dynamic memory variables, i.e. PRIVATE or PUBLIC variables, are used in the INIT procedure, they are declared with the MEMVAR statement.
LOCAL <var_Local> [:= <expression>]
Local variables are declared and optionally initialized using the LOCAL statement.
RETURN
The RETURN statement terminates an INIT procedure and branches control to the next INIT procedure. After the last INIT procedure has returned, control goes to the main, or root, procedure of an application.

Description

The INIT PROCEDURE statement declares a procedure that is automatically called when a program is started. There is one implicit INIT procedure named ErrorSys() that is invoked in all xHarbour applications. It installs the default error codeblock and is programmed in ERRORSYS.PRG.

INIT procedures do not have a list of arguments and no parameters are passed on program start. The execution order of INIT procedures is undetermined. It is only guaranteed that they are called when a program starts.

An INIT procedure cannot be called explicitely during the start sequence of a program since its symbolic name is resolved at compile time and does not exist at runtime.

Info

See also:EXIT PROCEDURE, PROCEDURE
Category: Declaration , Statements

Example

// See the example for EXIT PROCEDURE

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe