10-24-2008 05:52 PM
zientist wrote:Just wanted to ask, Troy why do you recommend to AVOID using global and local variables?
WIth local variables, you always have the potential of race conditions. For example in your case, the consumer loop can only stop if both, (1) the global is true AND (2) a queue element arrives. You can easily have a situation where the produce loop stops, and thus the "dequeue" operation will wait forever.
Local variables force extra datacopies in memory. This can be an performance issue when dealing with large arrays, for example.
Here's an old discussion. Read it! There are plenty more imilar discussions, just do a search.
10-26-2008 05:06 PM - edited 10-26-2008 05:06 PM
Ditto what altenbach said about local and global variables. (Asides from him being absolutely correct, who would argue with a 'Night of NI'!!!)
Using them can also make your code a LOT harder to debug when something goes wrong.
It takes a fair bit of practice and experience to code completely without local varibles but once you learn the techniques you'll realise your code is neater, more reiable and easier to debug.
It's the Shangri-la of LabVIEW coding.
10-26-2008 05:24 PM
10-26-2008 08:20 PM