PARAMETERS

PARAMETERS

Declares private parameter variables

Syntax

PARAMETERS <idPrivate list>

Arguments

<idPrivate list> is one or more parameter variables separated by commas.

The number of receiving variables does not have to match the number of arguments passed by the calling procedure or user-defined function.

Description

The PARAMETERS statement declares private variables to receive passed values or references. Receiving variables are referred to as parameters. The values or references actually passed by a procedure or user-defined function invocation are referred to as arguments.

When a PARAMETERS statement executes, all variables in the parameter list are created as private variables and all public or private variables with the same names are hidden until the current procedure or user-defined function terminates. A PARAMETERS statement is an executable statement and, therefore, can occur anywhere in a procedure or user-defined function, but must follow all compile-time variable declarations, such as FIELD, LOCAL, MEMVAR, and STATIC.

Parameters can also be declared as local variables if specified as a part of the PROCEDURE or FUNCTION declaration statement (see the example). Parameters specified in this way are referred to as formal parameters. Note that you cannot specify both formal parameters and a PARAMETERS statement with a procedure or user-defined function definition. Attempting to do this results in a fatal compiler error and an object file is not generated.

In Harbour the number of arguments and parameters do not have to match. If you specify more arguments than parameters, the extra arguments are ignored. If you specify fewer arguments than parameters, the extra parameters are created with a NIL value. If you skip an argument, the corresponding parameter is initialized to NIL. The PCOUNT() function returns the position of the last argument passed in the list of arguments. This is different from the number of parameters passed since it includes skipped parameters.

Examples

     .  This user-defined function receives values passed into private
        parameters with a PARAMETERS statement:

        FUNCTION MyFunc
           PARAMETERS cOne, cTwo, cThree
           ? cOne, cTwo, cThree
           RETURN NIL

     .  This example is similar, but receives values passed into local
        variables by declaring the parameter variables within the FUNCTION
        declaration:

        FUNCTION MyFunc( cOne, cTwo, cThree )
           ? cOne, cTwo, cThree
           RETURN NIL

See Also

 FUNCTION, LOCAL, PCOUNT(), PRIVATE, PROCEDURE, STATIC

ANNOUNCE

ANNOUNCE

Declare a module identifier

Syntax

     ANNOUNCE <idModule>

Arguments

<idModule> is a module identifier name.

Description

ANNOUNCE is a declaration statement that defines a module identifier. A linker may use this identifier later to satisfy pending module REQUESTs. ANNOUNCE and REQUEST provide a mechanism for managing application modules (.prg files).

Specify ANNOUNCE statements prior to any executable statements in a program file. A source (.prg) file can only have one module identifier; all subsequent ANNOUNCE declarations produce a compiler warning and will be ignored.

Module identifiers must be unique and should not duplicate the name of any procedures or user-defined functions in a source (.prg) file.

Examples.

// This example illustrates the ANNOUNCE declaration:

        ANNOUNCE CustomInit
        INIT PROCEDURE MyInit

           ? "Hypothetical Industries, Inc."

           RETURN

        /* 
        The above program module, CustomInit, should be compiled with the /N
        option.  Subsequently, the program is addressed in the source code of
        another program module through use of the REQUEST statement */

        REQUEST CustomInit

        which causes the module CustomInit to be linked into the resultant
        executable (.EXE) file.


Seealso 


REQUEST

Harbour Statements

Declaration

ANNOUNCE Declaration of a module identifier name
FIELD Declares a field variable
LOCAL Declares and optionally initializes a local memory variable
MEMVAR Declares PRIVATE or PUBLIC variables
PARAMETERS Declares PRIVATE function parameters
PRIVATE Creates and optionally initializes a PRIVATE memory variable
PUBLIC Creates and optionally initializes a PUBLIC memory variable
REQUEST Declare a module request list
STATIC Declares and optionally initializes a STATIC memory variable

Implementation

BEGIN SEQUENCE Declares a control structure for error handline
DO Executes a function or procedure
DO CASE Executes a block of statements based on one or more conditions
DO WHILE Executes a block of statements while a condition is true
EXIT PROCEDURE Declares a procedure to execeute when a program terminates
EXTERNAL Declares the symbolic name of an external function or procedure for the linker
FOR…NEXT Executes a block of statements a specific number of times
FOR EACH Iterates elements of data types that can be seen as a collection
FUNCTION Declares a function along with its formal parameters
IF Executes a block of statements based on one or more conditions
INIT PROCEDURE Declares a procedure to execeute when a program starts
PROCEDURE Declares a procedure along with its formal parameters
RETURN Branches program control to the calling routine
RUN Executes an operating system command
SWITCH Executes one or more blocks of statements
TRY…CATCH Declares a control structure for error handling

OOP

CLASS Define a Class for Object Oriented Programming
CLASSDATA Define a CLASSDATA variable for a class (NOT for an Object!)
CLASS VAR Define a CLASS VAR variable for a class (NOT for an Object!)
DATA Alternate syntax for VAR: instance variable for the objects.
ENDCLASS End the declaration of a class.
ERROR HANDLER Designate a method as an error handler for the class
MESSAGE Route a method call to another Method
METHOD Declare a METHOD for a class in the class header
ON ERROR Designate a method as an error handler for the class
VAR Alternate syntax for VAR: instance variable for the objects.
WITH OBJECT Identifies an object to receive multiple messages