Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Local vs private
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01039725
Message ID:
01040102
Vues:
20
>Hi,
>
>>>I don't use any PUBLIC variables. In my Main.prg, I create a PRIVATE var,
>
>So what's the difference between a PUBLIC var and a var declared as PRIVATE at the top level ?
>
>Regards,
>Viv

Public will create the variable, like Local, assigning .f. as default value. Another difference is that Public will survive any level, for example (sorry, just saw you said topLevel)
test2()
test3()

? somePubVar && somePubVar exists, defined in test1
? somePrivVar && somePrivVar does not exists

procedure test1()
? somePrivVar && Valid, defined in test1
? otherPrivVar && invalid, private does not define the variable
return

procedure test2()
public somePubVar
private somePrivVar, otherPrivVar
somePrivVar=0
test1()
return


procedure test3()
? somePubVar  && valid defined in test2 as public, value is .f.
? somePrivVar && Error, somePriv went out of scope already
return
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform