Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Messed Up Var refs?
Message
From
17/03/1999 14:53:02
 
 
To
17/03/1999 14:42:03
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00198800
Message ID:
00198807
Views:
19
>I'm having a queer problem where a bunch of variables seem to be set to the same memory location.
>
>What happens is that setting the value of any of these variables results in all of them being set to the same value.
>
>All the vars are declared in a PRIVATE statement:
>
>Those vars and some declared PRIVATE earlier on are affected.
>
>Any ideas as to what can cause this? it looks like VFP's memory allocater has gone belly up, and is assigning the same memloc to all new variables created.
>

Are you sure you don't want to make them LOCAL rather than PRIVATE? PRIVATE variables 'inherit' downward in the call stack, so that:

PROCEDURE PrivateVersion
PRIVATE cString, nNumber
cString = 'Apple'
nNumber = 42
DO SecondLevel
? cString, nNumber && side effect makes it banana 42

PROCEDURE SecondLevel
PRIVATE nNumber && hides any higher-level instance of nNumber
cString = 'banana'
nNumber = 16
RETURN

LOCALs do not inherit downward, so:

PROCEDURE LocalVersion
LOCAL cString, nNumber
cString = 'Apple'
nNumber = 42
DO SecondLevel
? cString, nNumber && no side effect; Apple 42


>Help!
>
>-- jas
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform