Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does public variable exist
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00892308
Message ID:
00892363
Vues:
23

Can "pemstatus()" be used to check for public variables created in the main program?
What object do PUBLIC variables exist in?
What's the best way to see if PUBLIC variables exist?

Thanks, Chuck


If you control the complete program code
and you do not use LOCAL/PRIVATE with the same name,
you can use VARTYPE() or TYPE().

If you write code into a black environment
VFP do not have a specific function for check if a variable is local,private or public:
VARLOCAL('byebye')
VARPRIVATE('byebye')
VARPUBLIC('byebye')
Hovewer, a local variable are known for definition into a static programming code,
then this is a false problem;
the question if the variable is public or private is not immediate.
I found only this way for do this:
PUBLIC byebye
byebye = 'PUBLIC'

CLEAR
innerproc1()
? 	m.byebye

innerproc2()
? 	m.byebye

PROCEDURE innerproc1
 PRIVATE byebye
 byebye = 'private'
 innerproc2()

PROCEDURE innerproc2
 * now i want know if byebye exists
 IF VARTYPE(m.byebye)=="U"
     ? "byebye nor exist"
 ELSE
     ? "byebye exist"
 ENDIF
* and it is public or private
 TRY
 	PUBLIC byebye && if byebye is public VFP ignore the command
 	? "byebye is Public"
 CATCH
  	? "byebye is Private"
 ENDTRY
If it is PRIVATE and you want known the number of PRIVATE levels,
you can known it only with a RELEASE and PUBLIC test loop.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform