I think golbal variables in general are viewed as flukey, as they tend to
reset themselves for no real reason. I use the global variable method as
well (I keep a public var for each datatype for exactly this purpose).
Speaking from experience, it gets to be a little confusing at times if
there's a lot of places you intend to do this. Most of what I use it for is
a popup search form, but I've often wondered about too many things going on
at once and the globals being read wrong. As a rule, I always set them back
to default or into a more appropriately scoped variable as soon as the
requirement for a global is up.
To get around the confusion of making sure that the same var will never be
used by different forms at the same time, you could always name seperate
global vars with different names for each place you want to use it, but that
becomes a lot of overhead memory for something that shouldn't need it.
After reading Marshal's solution, I had to stop and think about it for a
minute. But, I can see where his would be desirable... I've used these
'globals' in various projects for a few years now, and haven't run into any
issues yet, but hiding the form and closing it from the caller seems a bit
cleaner. I'll have to keep it in mind myself for future work.
--
Jack Leach
www.tristatemachine.com
- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain