Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing parameter by reference
Message
De
12/09/2011 05:31:51
 
 
À
09/09/2011 08:44:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01522925
Message ID:
01523199
Vues:
63
>>>Does anyone know of a way to determine if a variable has been passed to a function by reference or by value. This is a run-time question.
>>>For example:
>>>
>>>local a
>>>a='test'
>>>=Test(@a)
>>>=Test(a)
>>>
>>>procedure Text
>>>lparameter b
>>>*-- here, i would like to verify that the variable 'a' was passed to 'b' as by reference.
>>>...
>>>
>>
>>The best you can do is this.
>>Obviously it's no use.
>>
>>
>>PRIVATE a
>>a='test'
>>=Testa(@a)
>>=Testa(a)
>>PUBLIC x
>>=Testx(@x)
>>=Testx(x)
>>
>>procedure Testa
>>lparameter b
>>MESSAGEBOX("variable b "+IIF(VARTYPE(m.a)=='U',"Reference to a","is a stand-alone variable"))
>>
>>procedure Testx
>>lparameter b
>>MESSAGEBOX("variable b "+IIF(VARTYPE(m.x)=='U',"Reference to x","is a stand-alone variable"))
>>
>
>Thanks, I've looked at a simular approach. The problem is that the callee would not know the name of the argument the caller is using.

the bad side effect of this is that on VFP a public ( or private ) variable can disappear
without a reasonable:
PUBLIC x
ACTIVATE SCREEN
sideLevel1()

PROCEDURE sideLevel1(stop)
	? PROGRAM()
	? m.x
	IF m.stop
		RETURN
	ENDIF
	sideLevel2(@m.x)
	
PROCEDURE sideLevel2(stop)
	sideLevel1(.T.)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform