03-10-2007 07:24 AM
03-10-2007 08:42 AM
03-10-2007 08:53 AM
03-10-2007 09:09 AM - edited 03-10-2007 09:09 AM
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
03-10-2007 09:29 AM
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
03-10-2007 10:52 AM
03-10-2007 11:18 AM
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
03-10-2007 12:10 PM - edited 03-10-2007 12:10 PM
@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
03-10-2007 12:18 PM - edited 03-10-2007 12:18 PM
Again, the attached code will give you an array of zeroes and ones, showing the positions of the matches. 🙂
@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

Message Edited by altenbach on 03-10-2007 10:19 AM
03-10-2007 12:32 PM
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