Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Objects as Parameters
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00151207
Message ID:
00151236
Vues:
18
Michael,

What you've done certainly works. Generally it's ok for Visitor objects (oApp in your case) to "know" about the internals of the object they are visiting/manipulating. So it can just:

oApp.TestObj( oVar )

...
procedure TestObj( oVar )
oVar.nVar = oVar.nVar + 1
endproc
...

>I would like to pass objects and properties to library functions that will manipulate the values, and want to know the best or "right" way to do it.
>
>Here's one way I came up with:
>
>
>oApp = CREATEOBJECT("testproc")
>oVar = CREATEOBJECT("testobj")
>
>oApp.TestObj(oVar, "nVar")
>? oVar.nVar
>
>DEFINE CLASS TestProc AS CUSTOM
>	PROCEDURE TestObj
>	PARAMETERS oObj1, cVar
>	oObj1.&cVar = oObj1.&cVar + 1
>ENDDEFINE
>
>DEFINE CLASS TestObj AS CUSTOM
>	nVar = 0
>ENDDEFINE
>
>
>The TestObj procedure in the TestProc class simply increments the property in the passed object. The object is passed as-is, and the property is passed as a character string.
>
>This appears to work, but is this the proper way to do it? If not, how else does one send not only the object as a parameter, but a property as well, so that any changes will be reflected outside the procedure?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform