03-10-2010 05:07 PM
Hello guys.
I've got a problem with the Reverse 1D Array.I can´t get the result that the array is reverse.
If you have any suggestions for improving the program thank you.
Thanks
03-10-2010 05:27 PM
The functions that you are using from LabVIEW are definitely working. I took a quick look at your code, and it seems like your are using the "in range" function a lot. The limit from the code is between 0 to 18. If the value is outside that range, you will either get a 0 or 18, depending on what limit you cross. I run the program, and I got a -1 going into the "in range" function", so the result is 0. If you insert a 0 into an array, you are going to have an array full of 0s. If you reverse that array, the reverse version will look the same, since all the elements are 0s. Is that what you are seeing?
Yik
03-10-2010 06:56 PM - edited 03-10-2010 06:57 PM
@msap wrote:If you have any suggestions for improving the program thank you.
03-10-2010 07:30 PM
I agree altenbach.
But I thought I read somewhere it is better (more efficient) to write a value property than it is to use a local variable.
03-10-2010 07:43 PM
battler. wrote:But I thought I read somewhere it is better (more efficient) to write a value property than it is to use a local variable.
03-10-2010 10:03 PM
Ok, well what about Reading?
I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.
03-10-2010 11:50 PM
battler. wrote:Ok, well what about Reading?
I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.
If you can find a link or some sort of reference to where you read that, please post it.
I've always heard, and read, and seen with my own eyes that for performance reasons, a local variable should be used in place of value property node.
Not that there aren't places where a property node isn't the right thing to use.
1. You pass it a reference to a control so you can programmatically determine what control you want to change the value of.
2. You need the reference because you are changing the value in a different VI then where the control is located.
3. You want to use an error wire to control the order of execution.
4. You are already changing other properties of the control as well, so changing the value is just one more input that you can add to the list of properties in that particular node.
5. You want to use Value(signalling) so that you can trigger an event structure.
03-11-2010 12:11 AM
Ok, well what about Reading?
I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.
I believe that its best to use the local variable to pass the value to a control/indicator (like initializing or something like that) since only the data will be duplicated.
However A property node will surely duplicate the entire control/indicator to memory.
Or am i wrong?
Guru
03-11-2010 02:07 AM
Guruthilak wrote:I believe that its best to use the local variable to pass the value to a control/indicator (like initializing or something like that) since only the data will be duplicated.
However A property node will surely duplicate the entire control/indicator to memory.
Or am i wrong?
Guru
I'm not sure this is the point. I think the problem is that each property node always goes through the UI thread (thread switching), while a local variable can be updated in any thread.
Ok, well what about Reading?
I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.
Property nodes have the advantage that the data flow can be ensured using the error cluster. But this doesn't mean that property nodes should be used instead of locals.
03-11-2010 03:37 AM
Before the existence of tools such as the performance monitor and I was trying to optimise my code I gained the idea (from the NI documentation) that reading/writing to the Property node Value was more efficient than using a Local Variable. It is something which has stuck with me for a long while now.
I will keep searching through the NI docs I have. However, I did a Google search ad uncovered this for example:
When you make a local variable you make a local copy of the original variable. When you make a property node you make a reference to the original value.
In the case of single values the use of local variables may still be prefered because of the increase in readability. In the case of larger structures, such as an array, it is worth the effort to make the right property node.
http://www.morechemistry.com/labview/topic-optimize-for-speed/optimize.html