Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning an Array from a Function
Message
 
 
To
29/02/2000 10:24:55
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00338850
Message ID:
00339116
Views:
31
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform