Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Global variable dies when sent as a parameter??
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00179903
Message ID:
00180189
Vues:
25
>>If it's a global var, why are you sending it as a parameter?
>>Wouldn't the procedure have it available already?
>>Also, is the parameter name the same as the global var? If so PARAMETERS makes it private, which may kill it; LPARAMETERS makes it local, which will kill it.
>
>Hi,
>
>The procedure is called from anumber of different places and it is only sometimes a global variable is send as a parameter.
>
>The name of the globla variable is not the same as the parameter in the procedure. There is also no field with the same name as the variable or the parameter.
>
>Thanks for your thoughts...

I think I've found the problem. Do you invke the procedure with DO...WITH...? Passing a PUBLIC by REFERENCE (the default) results in the PUBLIC being hidden. the following code snippet demonstrates this nicely:
PUBLIC cTest
cTest = 'ByRef'
DO MyFunc WITH cTest
ctest = 'ByVal'
=MyFunc(cTest)
CANCEL

PROCEDURE MyFunc
LPARAMETER uVar
? uVar
? 'The type of the parameter is',TYPE('uVar')
? 'The type of the PUBLIC cTest is',TYPE('cTest')
RETURN
You can force a pass by value by invoking the procedure as a function, or by enclosing the argument to the WITH in parentheses to force a pass by value. This behavior of PUBLICs passed by reference is actually documented somewhere...
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform