LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Index

My application requires manipulation of an array index. When the array is empty, manipulation of the index does not work properly. To demonstrate the issue, I have attached a simple VI.

Two Questions:
1. Why the large "Index after?"
2. Why Zero?

Any ideas?
Thanks.
0 Kudos
Message 1 of 9
(4,021 Views)
You are doing math on unsigned intergers, they wrap for good reason.
 
The data range is applied to controls if the user enters a new value on the front panel. It does not apply to indicators or programmatic changes. Check the online help. Use "in range and coerce" from the comparison palette.
 
Can you explain why you need to manipulate index values? The index value has nothing to do with the size of the array, only with the value in the index terminal that shows which element is shown in the upper corner of the array display.
 
What are you actually trying to do? What is the purpose of the program?
Message 2 of 9
(4,015 Views)
You get the very large number because the array index is an unsigned number. With U32:

0 - 1 = 4294967295 (the maximum possible value)

Likewise:

4294967295 + 1 = 0 (the minimum possible value)

This is one more reason why you always have to be aware of the representation of numbers when you are doing math on them.

Mike...



Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 9
(4,014 Views)
The attached program is not the actual program. It's to demostrate the issue. In the actual program, it's an Array of Clusters and there is a need to access the data from the a cell before the index that the user is looking at or modifying...
0 Kudos
Message 4 of 9
(4,010 Views)
Thanks. Just wasn't paying attention and going by the color assumed it was an integer!
0 Kudos
Message 5 of 9
(4,008 Views)
Actually that was part of the point I was trying to make, it IS an interger and all integers will rollover because they have a maximum valuue they can hold.
For example, with an I32:

2147483647 + 1 = -2147483648

...it's just how computer-based integer math works.

Mike...

Message Edited by mikeporter on 06-07-2007 09:12 PM


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 9
(4,006 Views)
See attached for the behaviour I was expecting...
0 Kudos
Message 7 of 9
(4,001 Views)

Just change the representation of the indicators to I32 in the other case and it all looks better. (or change the terminals in this program to U32 to get the same you were seeing earlier. 😉

(To change the representation, right-click the terminal and select "representation".)

Message 8 of 9
(3,996 Views)
Oh I understand that this is what you were wanting. My point is that you can only get negative numbers with a numeric representation where negative numbers exist. I32s, because they are signed integers, have negative numbers. U32s being unsigned integers don't have negative numbers so you get results that seem odd. Actually the only problem is that we performed an invalid math operation.

Change the array of U32s to I32s and the math will behave as you expect.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 9
(3,995 Views)