Stanley,
Regarding public variables. I don't belong to the school that says you should
never use public variables. I do use them in a very limited way. In particular, I use them to hold references to global service objects that I want to call on throughout the application. For example, my Settings object, which enables me to store and retrieve system-wide settings at any point.
But I am very much against using public variables on the fly, in the way that you have done. If you just create a public variable for a specific short-term use, you run the risk that it will clash with other variables that you have created, perhaps in distant parts of the app - something that is almost certain to bring disaster.
In my own apps, I have adopted the following rules: (i) Use a naming convention that clearly indicates that a given variable is public; (ii) Declare and initialise all your public variables in the same place, near the start of the application; and (iii) Don't use public variables unless you can find no obvious alternative.
I'm sure many forum members will disagree with me, and say that you should not use public variables under any circumstances. That's fine. I won't argue with that. My rules reflect my personal preferences, but I would rather err towards not using public variables at all than using them too freely.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads