How FoxPro Passes Parameters to SubroutinesID: Q101025 2.50 2.50a 3.00 | 1.02 2.00 2.50 2.50a
The information in this article applies to:
SUMMARYBy default, FoxPro passes parameters to procedures (subroutines called with a DO <subroutine> command) by reference and parameters to functions [subroutines called with a =<subroutine>() or ?<subroutine>() command] by value. The information below describes how parameters are passed to subroutines.
MORE INFORMATIONWhen parameters are passed by value, a copy of the original variable is made in the routine. The variable declared in the subroutine is a different variable from the original variable. When control is passed back to the calling program, the variables declared in the routine are released and the value of the original variable is not changed. When parameters are passed by reference, a reference to the original variable is made in the routine. Any change made to the variable in the subroutine is reflected in the calling program.
Passing Parameters to User-Defined FunctionsBy default, parameters are passed by value to user-defined functions. In essence, any change made to the variables declared as parameters in the subroutine will not affect the original variables in the calling program. For example:
To pass a parameter by reference to a user-defined function, use the
at sign (@) before the variable passed. For example:
To change the default and pass all the parameters by reference, use
SET UDFPARMS command. For example:
Passing Parameters to ProceduresBy default, FoxPro passes parameters by reference to procedures. Any changes made to variables in the subroutine will be made to the original variable. Additionally, FoxPro hides the original variables passed as parameters in the subroutine. For example:
To pass a parameter to a procedure by value, use parentheses around
the variable. For example:
REFERENCES"Language Reference," version 2.5, page L3-1012 "Using FoxPro Version 2," Slater and Arnott, pages 613-614, Que, 1992 Additional reference words: VFoxWin 3.00 FoxDos FoxWin 1.02 2.00 2.50 2.50a 2.x array KBCategory: kbprg KBSubcategory: FxenvMemory
|
Last Reviewed: May 13, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |