LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the latest number in array

Solved!
Go to solution

I am reading a CSV file and the input has a serial number. When inputting the number, I have it output certain variables which is in my code. I am trying to figure out how to do such a task where the program will check if there are more than one matching serial numbers and then pick the one that is the newest (the date and log time are closest to real time). Can someone help me

0 Kudos
Message 1 of 8
(3,072 Views)

Try reversing the array before the search.  Then you just subtract the array length-1 (ie the final index) and the found index.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 8
(3,062 Views)

I implemented this but it did not change my solution. When I inputted the serial number, I still received the same value as before. 

0 Kudos
Message 3 of 8
(3,033 Views)

Show us your updated code so we can verify the issue.  It worked for me.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 8
(3,029 Views)

Here is my code

0 Kudos
Message 5 of 8
(3,021 Views)
Solution
Accepted by topic author sportsguy99

Remove the Start Index on the Search 1D Array.  You are essentially skipping the last row.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(3,015 Views)

Why are you using the array size, the -1 to the index and then the subtraction of both of them?

0 Kudos
Message 7 of 8
(2,992 Views)

Size-1 is the index of the final element.  If we have 3 items in the array, the size will return 3, but the final index is actually 2 (0, 1, 2).  Therefore we have to subtract 1. We will just call that final index N.  So when we reverse the array, what was at N is now at 0.  So N-0 = N (index of item in the non-reversed array).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(2,982 Views)