03-18-2012 12:44 PM
Hi
I have built a vi which has eventually become huge with lots of sequence and cases. Local variables sure reduces a lot of wires but at the same time consumes memory. So which ones better? wires running throughout the vi or local variables?
Regards
sarkar
Solved! Go to Solution.
03-18-2012 12:50 PM
03-18-2012 01:00 PM
Thanks Ravens. I am just getting the hang of Labview
Regards
sarkar
03-18-2012 01:11 PM - edited 03-18-2012 01:16 PM
@chips wrote:
I have built a vi which has eventually become huge with lots of sequence and cases. Local variables sure reduces a lot of wires but at the same time consumes memory. So which ones better? wires running throughout the vi or local variables?
Since local variables break dataflow, they often necessitate the use of sequence structures to enforce correct execution order. If you use wires, many of your sequences can probably be eliminated, greatly simplifying your code. Unless you are dealing with large data structures (such as big arrays), memory is typically not of concern. The problem with local variables are race conditions and unmaintainable, overly complicated code.
Also note that a single VI should NEVER become "huge" by any definition. Structure your code into subVIs and used a well established modular design pattern.
Feel free to show us your code, maybe we can give more specific feedback to get you started in the right direction. 🙂
03-18-2012 01:26 PM
Okay so if i have a if structure like if (x && y)
num=1
else if (y && z)
num =2
else
num=3
How do i change the value of numeric indicator (num)without using local variable?
03-18-2012 01:38 PM - edited 03-18-2012 01:39 PM
Is num an indicator?
Put the indicator outside the case structures and put the various constants inside the respective cases wired out of the case structure by way of tunnels.
03-18-2012 01:41 PM
Its going to be a very very complex case structure. But then i will prefer complexity to possible race around condition
03-18-2012 01:42 PM
Thanks for your time 🙂
03-18-2012 08:13 PM
How to implement it depends on exactly what you are trying to do. But your biggest problem is that you are trying to write LV code while thinking in C. They are two different languages and require different approaches and different ways of expressing the solution to the same problem.
Where are the numbers coming from? is the user entering them? are they coming from a DAQ device?
Mike...
03-19-2012 03:41 AM
Yes Mike i am new to LV and user is entering the data.