Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Global variable
Message
 
 
À
22/05/2002 12:01:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00659966
Message ID:
00660807
Vues:
9
>Hi all,
>
>I am a new learner in Visual Foxpro. Now try to use it to develop some project for myself. I am quite familiar with VB and assume that the programming in visual foxpro should be quite similiar but somehow i am wrong.
>
>I try to assign a global variable but never able to do so. When i type in "Global try_variable" under init in main form, it keep saying unrecognized command verb. I try to search through my foxpro book but no example of global variable assignment.
>
>Any one can tell me how i should do it ? and what good reference book i can get for Visual foxpro (I using version 6)
>
>Thank you and best regard
I little confusion can be caused if you are not aware of the SCOPE of a var.
class hierarchy
OBJECT1
   PUBLIC var1
   var1= "TEXT"
   var2= "WORD"
     OBJECT2
        PRIVATE var2
        var2= "TEST"
          OBJECT3
             LOCAL var4
             PUBLIC var5
             var4= "DATE"
             var5= "NUMB" 
var1= "TEXT" and var2= "WORD" in OBJECT1, what are the var-values in OBJECT2?
var1= "TEXT"
var2= "TEST"
Note that if OBJECT2 is released,
var2 is again "WORD" because var2 in OBJECT2 was PRIVATE in OBJECT2!

If you are expecting var2= "TEST" after OBJECT2 is closed you will error.
If you expected var2="WORD" while OBJECT2 procdure runs you will error.

further,
var4 only exist while OBJECT3 procedure is open and
var5 is only available during and after OBJECT3 runs.
If you alter OBJECT3 (WHICH is called from OBJECT2) var2 to "GOOD"
even after OBJECT3 is released and var2 will remain "GOOD" until OBJECT2 is released, where var2 is again recognized as "TEST".

hth
Edgar L. Bolton, B.S. B.B.A.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform