LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to comparing enable indexing string with a string

Hi,
 
How can string values that in being indexed be compared with a single string value that is the output from a flat sequence structure. The disable index in greyed out for the string that is the output from the previous flat sequence structure. hopefully the image provides more detail.
 
thanks
 
King1
0 Kudos
Message 1 of 16
(3,754 Views)
You are comparing the entire string from the precious frame to each one that is in the array. You can't enable indexing because the string is not an array. Why would you want to enable indexing in the first place? You'll have to explain a lot more if your are having problems. It would help if you could also provide some sample data that you are working with.
0 Kudos
Message 2 of 16
(3,736 Views)
Hi,
I am sorry for not providing enough information but basically i want to compare a string with an array, the string is given from a flat sequencen structure before. Then each time the string is equal to the indexing array i get an 1 as the output.
 
ARRAY            STRING
Craig               Craig
Jon
Bill
Craig
 
This example would give an output of 2, because the string matches an element of the array.
 
thanks
KING1
 
 
0 Kudos
Message 3 of 16
(3,736 Views)

Okay. first let me explain why you are not seeing your expected match. A for loop will iterate a number of times equal to the size of the input array. If you find a match at element 2, for example, the for loop will continue doing the comparison. So, for the next series of comparisons, the match will fail. At some point, the indicator you have will change to one but the loop is running so fast, you won't ever see it.

You are also making the task much more difficult than it has to be. There is a function called Search 1D Array. All you have to do is wire the string array up to the 1D Array input and your string from the earlier frame to the element input. If there is a match, the index of element output will have the index of the matching string in the array. If the output is -1, there was no match. So, all you have to do is have a >= 0 comparison on the output to know if there was a match.

p.s. From what you've posted, the sequence structure can be eliminated. It's better to learn correct dataflow programming and not use the sequence structure.

Message Edited by Dennis Knutson on 03-10-2007 08:10 AM

0 Kudos
Message 4 of 16
(3,731 Views)

Hi,

This method will only indicate that there is a match if i am correct, it will not indicate EACH time there is a match. What i am looking for is a way of indicating a 1 each time the string matches otherwise i get a 0. I need away of indicating EACH TIME the string matches. NOT just there is a match, how could this be created.

Thank you

King1

0 Kudos
Message 5 of 16
(3,724 Views)
There are several ways. Here are a couple. Both of them make use of a basic element in LabVIEW called a shift register.
Message 6 of 16
(3,716 Views)

Hi Dennis,

Thank you very much for you help, the first method work , but iam not sure why the second method didn`t work.

 

thanks

KING1

0 Kudos
Message 7 of 16
(3,711 Views)


@King1 wrote:
...., but iam not sure why the second method didn`t work.

Dennis did not show what's in the TRUE case, so what did you put in there? It shoud have a "build array" node with two inputs. Wire the upper input tho the wire coming from the left shift register, wire the [i] wire to the lower input, and wire the output to the tunnel going to the right shift register. Did you do that?

Anyway, if you just need the total number of matches ( and don't need the actual positions of the matches), you can do things even easier, see image. 🙂

Look Ma, no loops! 😄

Message Edited by altenbach on 03-10-2007 10:11 AM

0 Kudos
Message 8 of 16
(3,697 Views)

@King1 wrote:
What i am looking for is a way of indicating a 1 each time the string matches otherwise i get a 0. I
Again, the attached code will give you an array of zeroes and ones, showing the positions of the matches. 🙂

Message Edited by altenbach on 03-10-2007 10:19 AM

0 Kudos
Message 9 of 16
(3,691 Views)

Hi altenbach,

I am not sure on what you mean  about the true part could you please put up a PNG, I want to compare a string with a array evey time it matches i need to show a 1 and each time there is no match it shows a me a zero. The way Dennis has done it, it shows the total number of matches, i need to see each time a match occurs i get a 1.

 

thanks

KING1 

0 Kudos
Message 10 of 16
(3,681 Views)