From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array-Search-Function

Hi @all,

i try to find out a solution for this problem. I have a text-file, which was transmit in to an array. The array has 6 coulums and a lot of rows. The text-file ends with the string "END". Now i have 6 string-inputs, which i have to compare with every row. Input 1 shows the coulum 1, Input 2 shows the coulum 2 and so on. Now i'll write a vi, what can compare the input with the hole list in the array and find out if there is a hole row equal with the input. A "XX" in the list, means that the input is every time equal!!!

For the better understanding i have the input-text-file and a vi, which generate the array and show it to you.

For example: Input 1 is equal to any string in coulum 1, the you have to compare input 2 in the same line. If it equal to you have to check input 3 with coulum 3 at the the line. If all inuputs a equal it's a goal!

Please help me!

Thanks Thomas
0 Kudos
Message 1 of 11
(3,000 Views)
Hi @all,

here is the input-text-file

Thanks Thomas
0 Kudos
Message 2 of 11
(2,989 Views)
Hi Thomas

Try this....


Rob
0 Kudos
Message 3 of 11
(2,975 Views)
Hi Gandalf,

this is a good solution. Thank you! But one question i have to you. It is possible to change this function, that in any case, where in the input file is a "XX" it's a good compare with the input?

For example: Input1: 3A192646 Input2 : XX Input3 : 19 Input 4: XX Input5: 05 Input6 : 10
Array: Row1/c1: 3A192646 row1/c2: 69 row1/c3: 19 row1/c4: 23 row1/c5 05 row1/c5: 10

------> this have to be a hit too

Thanks Thomas
0 Kudos
Message 4 of 11
(2,974 Views)
Well, it seems you just have to compare each row until you found a match or END is reached.

This is easily done in a while loop. The attached example show one possibility )LabVIEW 7.1). Let me know if you have questions.

The loop stops of a row is matched, if END is reached OR if the first element in a row contains an empty string (e.g. if you would read a file with no matching row and the END line missing by accident. It would never stop otherwise). 🙂

(I don't understand what you were trying to to with the sequence structure, so I simplified things).
0 Kudos
Message 5 of 11
(2,972 Views)
Hi Altenbach,

the compare-function find out if a hole line is equal to all inputs. But i need a hit if the input is for ex. 25 and in the array is "XX". Look up in the reply in front of your answer.

So i think we have to compare every element with the input or not?

Thanks again!

Thomas
0 Kudos
Message 6 of 11
(2,967 Views)
OK, here's a solution that forces a match for items where the input contains an XX. Is that what you want?

Message Edited by altenbach on 06-10-2005 12:43 AM

0 Kudos
Message 7 of 11
(2,967 Views)
Hi altenbach,

yes this is it what i want. But i have make a mistake. i want a hit if in the data-file is an "XX" and the input is any other. But i have one little thing change in your vi and now it works i think.


thanks Thomas
0 Kudos
Message 8 of 11
(2,956 Views)
Hi @all again,

it is possible to change the vi in this case, that the loop stops if there is a hit (i think it works) and a output which shows if there is a hit, or there is no hit(boolean).
But the loop stops if the array ends. Do you know. I'll use this vi as sub.vi with 5 Inputs and 1 array input and it should show me if there is a hit or no hit (output=boolean)

I Think it is easy but , if havn't found a goog solution.

Thanks All,

Thomas
0 Kudos
Message 9 of 11
(2,945 Views)
In this case, you only need one match (1D array, not 2D array), one index (not an array), and one boolean (not an array).

The loop should stop if (1) a match is found, (2) END is reached, (3) or the file ends. For case (1) we need to show the first match as 1D array, Hit? = true, and the row index of the found item. In all other cases, the match is an empty array, Hit? = false, and index = -1.

The attached modification should do this just fine. I have changed the input to an array, it seems cleaner (change it back if you want). I also have placed a real number in position 5 as default value to make sure it is ignored because of the XX in the file. The default values should find a hit in column 36 for demonstration.

You still need to make it into a subVI and hook up the terminals. Good luck.
0 Kudos
Message 10 of 11
(2,930 Views)