Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive Remove Directory
Message
De
10/12/1999 22:35:46
 
 
À
10/12/1999 21:28:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00302015
Message ID:
00302162
Vues:
39
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform