Hackers Guide to Visual FoxPro 7.0
LParameters, Parameters, Set UDFParms, Set("UDFParms")
PARAMETERS and LPARAMETERS specify the formal parameters for a procedure or function. SET UDFPARMS determines whether the default for parameters sent to functions is passing by value or by reference. (For basics on parameter passing, see "Pass the Parameters, Please" in "Xbase Xplained.")| Usage | LPARAMETERS Parameter1 [ AS Type1 [ OF ClassLib1 ] ] [, Parameter 2 [ AS Type2 [ OF ClassLib2 ] ] [, ] PARAMETERS Parameter1 [ AS Type1 [ OF ClassLib1 ] ] [, Parameter 2 [ AS Type2 [ OF ClassLib2 ] ] [, ] |
| | VFP 7 mishandles multi-line parameter statements for methods. When you create a subclass and one of the methods of the original class has a multi-line parameter list, the parameter list for that method of the subclass all appears on a single line. In VFP 6, any tabs or spaces that were placed at the beginning of the second and subsequent lines are removed; in VFP 7, those tabs and spaces are copied into the single line. |
| | In addition, under some circumstances in the original release of VFP 7, if the parameter statement isn't the first in the method, it doesn't get copied to the same method in a subclass. This bug is fixed in Service Pack 1. |
LPARAMETERS or PARAMETERS must be the first executable statement in the routine. This means the only things that can be put between the FUNCTION or PROCEDURE line and the parameter declaration are comments and compile-time directives, such as #INCLUDE and #DEFINE.
LPARAMETERS creates the parameters as local variables, while PARAMETERS makes them private. We strongly recommend you use LPARAMETERS unless you have a specific reason not to. You can only use one or the other in a given routine. As soon as FoxPro finds a parameter declaration, it rejects any other.| | You can also list parameters as part of the function or procedure heading. Parameters created that way are local. See the comments in the example below for an example of how to do this. |
| Example | FUNCTION OneName * Take a first name and last name and return one name. * If either parameter is missing or is the wrong type, * return the empty string. * The heading could be: * FUNCTION OneName(cFirst, cLast) * instead, and the LPARAMETERS line omitted, * with the same effect. LPARAMETERS cFirst, cLast * Test parameters. IF PCOUNT() < 2 RETURN "" ENDIF IF TYPE("cFirst") <> "C" RETURN "" ENDIF IF TYPE("cLast") <> "C" RETURN "" ENDIF RETURN TRIM(cFirst) + " " + TRIM(cLast) |
| Usage | SET UDFPARMS TO REFERENCE | VALUE cParmSetting = SET( "UDFPARMS" ) |
| See Also | Function, Local, Parameters(), PCount(), Private, Procedure, Set |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории