MartyConnelly
martyconnelly at shaw.ca
Tue May 17 11:50:59 CDT 2005
Just to clarify something from the mysts of tyme. A variable defined with the GLOBAL keyword is available to any code in any module in your project. All code sees and sets the same data. This is essentially a VB 3.0 method and the PUBLIC keyword which was introduced in VB 4.0 is generally preferred over GLOBAL. The PUBLIC keyword introduced in VB4 and VB5 allowed you to create a module-level variable that can still be accessed by code in other modules. I believe the use of "Global" in a code module is more descriptive than "Public"; the Public keyword has two meanings: in a BAS code module. It means Global any in any other module type. Using Public in forms and classes makes sense but in BAS modules the use of Global immediately identifies the scope without having to back up and check what module type you are in. This really goes back further than the mysts of time into the early paeolithic. Fortran II had a global common area for variables, Fortran IV had a labelled global common area. These were used for a variety of reasons, old Fortran guys hated keypunching long subroutine calls with about 40 variables, it also saved memory as you could equivalence common areas, so if you had requirements for 2 (1000,1000) arrays you could map the same memory area to them. This method was used in Cobol and PL1 and algol. However you had to be very careful with the order and type of variables in a common area. This has declarative changes in Fortran 90 and 95 but by then they had take out the computed GOTO, *sob* Gustav Brock wrote: >Hi John > >Well, here we have full control on where functions put their nasty >fingers. > >I haven't managed yet to build self generating code; to some this would >indicate a brave new world, to some it would be a nightmare - functions >creeping around and attacking our globals and eating our children... >gosh. But worse, they would soon learn how to take advantage of your >functions to change those "private variables"! Be prepared. > >/gustav > > > >>>>jwcolby at colbyconsulting.com 05/16 10:58 pm >>> >>>> >>>> > >.. Making this a global allows functions >that have no business setting these variables to change them. By >having a >private variable returned by a public function, any function that needs >the >information can get it but cannot modify it. > > > -- Marty Connelly Victoria, B.C. Canada