Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Objects getting clobbered - scope problem?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00913041
Message ID:
00913056
Views:
19
Hi Michel,

I don't see this in my test. What I'm doing differently? Running VFP8SP1.
oRec = Null
=f1()
RETURN

FUNCTION f1
*LOCAL oRec
CREATE CURSOR testxx1 (ii1 int, cc1 char(2))
INSERT INTO testxx1  VALUES(1, "#1")
SCATTER NAME oRec
? oRec.ii1, oRec.cc1
=f2()
? oRec.ii1, oRec.cc1     && oRec object wasn't changed after call to f2()
RETURN

FUNCTION f2
LOCAL oRec
CREATE CURSOR testxx2 (ii1 int, cc1 char(2))
INSERT INTO testxx2  VALUES(2, "#2")
SCATTER NAME oRec
RETURN
>I have an application which creates an object (SCATTER NAME) which then calls a function which happens to create an object by the same name. The function destroys the object before returning.
>
>I was expecting that by defining the object as LOCAL or PRIVATE within the function, it would not clobber the identically named object in the calling function. I appear to be wrong because the object in the calling program is getting clobbered by the one in the function.
>
>Either I'm not understanding how to properly scope the object in the calling and called function, or objects behave differently than other variables.
>
>Can someone shed light?
>
>TIA
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform