Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recursive Remove Directory
Message
From
10/12/1999 22:35:46
 
 
To
10/12/1999 21:28:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00302015
Message ID:
00302162
Views:
38
>Oh. Since they're not local, are they public?

No, they are not public. They are a weird kind of animal! They behave as private /public variables for all called func/proc/methods. But they are released as soon as the func where they ar declared is finished.

The following code will print:

x = 2
y = 1

*-- Code start
x = 1
y = 1
do AProc
? "x=", x
? "y=", y

procedure AProc
	x = 2
	private y
	y = 2
return
In VFP, PRIVATE only hides any variable with the same scope from any higher level. It does not allocate memory for the variables declared PRIVATE and the type of those variables is undefined until they are actually initialized.

Run the following piece of code and see the results:
? "x type:", type("x")
private x
? "x type after PRIVATE:", type("x")
x = 1
? "x type after initialization:", type("x")

? "y type:", type("y")
local y
? "y type after LOCAL:", type("y")
y = 1
? "y type after initialization:", type("y")
This is another difference between PRIVATE and LOCAL, because LOCAL actually creates the declared variables.

Vlad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform