09-20-2005 10:48 AM
09-20-2005 12:31 PM
09-20-2005 04:56 PM - edited 09-20-2005 04:56 PM
Message Edited by aartjan on 09-20-2005 11:57 PM
09-21-2005 01:12 AM
09-21-2005 01:59 AM
09-21-2005 02:32 AM
09-21-2005 11:55 AM - edited 09-21-2005 11:55 AM
Most people shy away from Globals because of the possibility of race conditions. That is where a global might be read before it is written, or vice versa, in a manner that the wrong data gets read. Since you write once and read once, you only have to ensure that the writting is done before the global is read, by using either data flow methods or sequence structure. Once you are sure that you won't have a race condition, it is perfectly OK to use globals. That is what they are there for. I use globals as constants to hold GPIB addresses, calibration factors, and other things that are defined upon creation and never changed. Can't have a race condition if the global is never written to.
See the attached example for how a race condition can occur.
Message Edited by tbob on 09-21-2005 10:56 AM
09-27-2005 04:10 AM