Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with a Foxpro programming question
Message
 
À
09/09/2000 12:48:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00414601
Message ID:
00414613
Vues:
22
Phil,

About the declaration of variables in FoxPro.

In fox you don't need to declare a variable as a integer, a character, a string etc.
FoxPro just determines that self when using the variable.

But what you can do is defining the scope in which the variable will be used.
You have tree, local, private and public declarations.
Local defined declarations are visible only in the function or method where it is declared.
Local lcLocalVar
Private defined variables are visible in the function or method in which it is declared and also in all the functions that are called by that method.
When you do not declare a variable it defaults to be declared private.
Most programmers (me too) do recommend to use this type of declaration as less as possible.
Function A()
Private pnPrivateVar
  Do B
  ? pnPrivateVar
EndFunc

Function B()
  pnPrivateVar = 12
EndFunc
The third type of declaration is public declaration. A public declared var is visible in the whole application.
Public gcDataDir
gcDataDir = 'C:\Test\'


Most Foxpro programmers also use a two letter code in front of the variablename.
This helps you to quickly see what kind of variable you are speaking of.

the first letter stands for the scope of the variable.
l = Local
p = Private
g = Public (Global)

The second letter stands for the type of the data you will store in the var.
n = numeric
c = character
a = array
d = date
l = logical
etc.

This is a short explanation of the variable declaration.

I hope it may help you.

Succes on using VFP,
It's a great language.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform