On Sep 22, 2009, at 6:24 AM, Bill Zielenbach wrote: > The problem is with the global variables, which will overlap between > functions. (Function A depends on global variable > sets x and y, and Function B depends on global variables set, y and z) Robert responded on most of the issues mentioned, but a couple of tidbits regarding global variable use might be helpful for many on the list. As many of us have discovered, global variable use has advantages and disadvantages. One goal is to minimize the disadvantages. Program restructuring and maintenance is more difficult with functions dependent on global data ( often called 'tightly coupled' in my old programming classes ). Avoiding global data eliminates issues associated with tightly coupled functions, but, obviously, global data cannot always be eliminated entirely from a project. A couple of techniques to mitigate the disadvantages of global data are: (1) Change global data in only one location ( such as in one function ). Create 'setter' and 'getter' functions for just one piece ( or one logical unit ) of discrete global data. local fn MyLongSetter ( longValue as long ) gMyGlobalRec.myLongData = longValue end fn local fn MyLongGetter end fn = gMyGlobalRec.myLongData (2) When a function has to use global data, pass it by value to the function( instead of using the global directly within the function ). This gives the function access without the ability to change it ( compared to passing by reference which would allow the global to be changed ). local fn SomeFunc( myPassedData as short ) // use myPassedData within the function end fn fn SomeFunc( gMyGlobalRec.myShortData ) Other techniques and extensions of the above ( such as setting all the fields in a global record ) are possible. None of these techniques are enough to solve all issues with global data, and retrofitting techniques to an existing program is always more difficult than doing this planning before writing any code. The reward for thoughtful program construction planning emerges when a program starts its first maintenance cycle. Brian S.