Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning an Array from a Function
Message
 
 
À
29/02/2000 10:24:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00338850
Message ID:
00339116
Vues:
30
Okay now I'm really confused. I took your code and made some slight modifications to it (see below) and I got the following results:
First .F.
First .T.
Second .T.

local oObj
oObj = createobject("oFirst")

?oObj.Name, transform(pemstatus(oObj,"testpem",5))
ChangeObject(oObj)
?oObj.Name, transform(pemstatus(oObj,"testpem",5))
ChangeObject(@oObj)
?oObj.Name, transform(pemstatus(oObj,"testpem",5))
return

function ChangeObject
     lparam toObj
     toObj.AddProperty("testpem")
     toObj = createobject("oSecond")
endfunc

define class oFirst as custom
     name = 'First'
enddefine

define class oSecond as custom
     name= 'Second'
     testpem = .T.
enddefine
So you can add/modify properties of a passed by value object but you can't modify the object itself. But if you do pass it by reference (@) then you can actually change the object.

Object variables have their own set of rules is what everyone is telling me. Since I only pass object variables by value and I know this behavior (if not explicitly then intuitively), I can live with it.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform