05-10-2012 11:05 PM
Okay. Then don't listen to the experts on the forum. And please keep posting questions about how your code doesn't work like you expect it to.
05-10-2012 11:26 PM
@iCat wrote:
@Ravens Fan wrote:
It would solve your race condition problem.
I don't see where you have a spaghetti code problem. Eliminating local variables, straightening wire runs, and sorting things out so wires don't run backwards will make the code look better.
The screenshot of my code reminds me of sparse spaghetti.
If I add a few more wires crossing over other wires perpendicularly, others will have difficulty reading my code.
You are making the code to work and you will give the user only the front panel and don't much bother to make your code readable to others. Make documentation that is sufficient for others to understand. Just check the size of your code and understand why Knights are advising to remove the local variables.
05-11-2012 12:47 AM - edited 05-11-2012 12:48 AM
@P Anand wrote:
@iCat wrote:
@Ravens Fan wrote:
It would solve your race condition problem.
I don't see where you have a spaghetti code problem. Eliminating local variables, straightening wire runs, and sorting things out so wires don't run backwards will make the code look better.
The screenshot of my code reminds me of sparse spaghetti.
If I add a few more wires crossing over other wires perpendicularly, others will have difficulty reading my code.
You are making the code to work and you will give the user only the front panel and don't much bother to make your code readable to others. Make documentation that is sufficient for others to understand. Just check the size of your code and understand why Knights are advising to remove the local variables.
Assume that I have a control that has a default value. And I take measures to never write to the control.
If I only read from local variables for the control, would it be acceptable to use local variables for the control?
05-11-2012 12:53 AM
If you are not using the control then why don't you make it as a constant and wire wherever required. I don't understand why you are fighting to use Local variables.
05-11-2012 02:39 AM
@P Anand wrote:
If you are not using the control then why don't you make it as a constant and wire wherever required. I don't understand why you are fighting to use Local variables.
Does LabVIEW has a constant that can be used in more than one places?
Since the constant has to be used in many places and I need to change the value of it often,
I need the constant to be shared.
05-11-2012 02:59 AM
More than one places means in the same vi or in sub vis?
05-11-2012 03:20 AM
in the same VI.
05-11-2012 03:27 AM
Then keep at the beginning and wire it wherever it is required.
05-11-2012 03:58 AM - edited 05-11-2012 04:00 AM
In general, if you encounter your code to become "spaghetti", it is most likely that the block diagram is also growing in size. So the easiest thing to fight BD size as well as spaghetti is to create subVIs. If done properly, you will be rewarded with easy to read code and reusable modules.
Norbert
EDIT: You should focus on redundant code segments first. Esp. case structures tend to include such segments because you always only see one case at a time, hiding all the other code.
05-11-2012 05:53 AM
It literally looks like the spaghetti I ate yesterday. Well, mine was spaghetti squash instead of pasta, but they don't taste the same.