Note | This command is only available in the FOXPRO dialect |
The LPARAMETERS Statemenent is identical to the PARAMETERS statement.
The Variables however will be created as LOCAL variables and not as Dynamic Memory Variables and the optional <Type> clause is respected.
Create local variables to receive passed values or references.
LPARAMETERS <idParameterList>
LPARAMETERS <Parameter1> [ AS <Type> [ OF <ClassLibrary> ] ] [, <Parameter2> [ AS <Type> [ OF <ClassLibrary> ] ] ]
<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. |
The <ClassLibrary> is ignored but the <Type> is enforced. |
When a LPARAMETERS statement executes, all variables in the parameter list are created as local variables.
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()
LPARAMETERS cOne, cTwo, cThree
? cOne, cTwo, cThree
The next example is identical, but receives values passed into local variables, declared within the FUNCTION declaration:
FUNCTION MyFunc(cOne, cTwo, cThree)
? cOne, cTwo, cThree