LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While using search 1d array, if element searching is 0 sends the index as -1.

Hello all,

 

I have been facing a slight issue while using search 1d array in my code.

I use a text file with multiple columns, I use one column to get the index of that row to send values from a different column. This works fine as long as the element that is being searched is not zero.

 

When the element is 0 then the index is sent out as -1 affecting the logic, need some help fixing that.

Thanks a lot.

 

0 Kudos
Message 1 of 11
(2,786 Views)

We cannot help unless you attach your VI and some data. How do you read the file (A string with multiple columns is not an array!) What are typical values of the elements, e.g. element 0? Could it be there are hidden characters (change string to \-codes display to check).

0 Kudos
Message 2 of 11
(2,774 Views)

-1 means it wasn't found within the array.  Is it in the array?  to altenbach's point data really matters here.  For example if its a string array containing "0.00" and you search for "0" it's not an exact match. and therefore says that it couldn't find what you're looking for.

0 Kudos
Message 3 of 11
(2,766 Views)

I have added the snippets of the code and the file I use to search and send.

 

Download All
0 Kudos
Message 4 of 11
(2,755 Views)

These are not snippets, just useless truncated pictures. Attach the VI and data file!

Why are there so many local variables? What's the value of "PLT" and where does it come from??

 

You are dealing with DBLs, not strings, so all limitations of doing equal comparisons on DBls apply, of course.

0 Kudos
Message 5 of 11
(2,752 Views)

I have attached the VI, please find the attached.

0 Kudos
Message 6 of 11
(2,738 Views)

We also need a datafile to read.

0 Kudos
Message 7 of 11
(2,736 Views)
0 Kudos
Message 8 of 11
(2,734 Views)

We are also missing all your subVIs. What's the value coming out of "line sensor" cluster element.

 

Please boil down the problem to something simple, e.g. as follows: Make sure the string control has the exact value.

 

Linsesensor.png

 

Also note that your file has a header row. Are you accounting for that?

0 Kudos
Message 9 of 11
(2,714 Views)

This is based on some parsing using the serial data coming from the device I am using. I am trying to send the values runtime using some data coming from the device.

 

These are the two sub VI's. The Line sensor value coming from the cluster is parsed from a logline coming from the device.

Download All
0 Kudos
Message 10 of 11
(2,704 Views)