Note | This command is not available in the Core and Vulcan dialects |
Create private variables to receive passed values or references.
PARAMETERS <idParameterList>
PARAMETERS <Parameter1> [ AS <Type> [ OF <ClassLibrary> ] ] [, <Parameter2> [ AS <Type> [ OF <ClassLibrary> ] ] ] // FoxPro only
<idParameterList> | One or more parameter variables separated by commas. These variables are used to receive arguments that you pass when you call the routine. The variables will be dynamic memory variables |
<Type> & <ClassLibrary> | The compiler recognizes the AS <Type> and the AS <Type> of <Classlibrary> clauses in the FoxPro dialect. |
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 function terminates. A PARAMETERS statement is an executable statement and can, therefore, occur anywhere in a procedure or function.
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 within a procedure or function definition.
Attempting to do this results in a compiler error.
The number of receiving variables does not have to match the number of arguments passed by the calling routine. 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 than the number of parameters passed, since it includes skipped parameters.
This function receives values passed into private parameters with a PARAMETERS statement:
FUNCTION MyFunc()
PARAMETERS cOne, cTwo, cThree
? cOne, cTwo, cThree
The next 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