LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to pass data to arrays based on the value of first 4 digits of 7 digit strings

Solved!
Go to solution

I want to sort incoming data, into various arrays based only on the first 4 digits of each string.

For example a hex string could be 41322033333533 which is A1 3353.

A1 stands for a particular sensor., and I want to sent all the A1 data to an array.I have data coming from 8 sensors, and want to send the data to separate sensor arrays. My sensor names are A1,A2,A3, T1,T2,T3,W1

I was going to use a case structure, for loop and an '=' comparison for the data. However I only want to compare the first 4 digits of the string and I cannot find an operator for this. Any advice on how to do this would be appreciated.

 

0 Kudos
Message 1 of 9
(3,364 Views)

Try using the "string subset" function to get the first 4 digits of the data and compare that

0 Kudos
Message 2 of 9
(3,359 Views)

Yes but if I do that dont  I lose the rest of the string, which is the sensor value I wish to store in an array?

0 Kudos
Message 3 of 9
(3,356 Views)

Nope, what this function does is to create a separate, independing string containing X digits past Y offset. The original is unchanged, any "subset" LabView functions don't alter the original in any way unless you programatically say so.

0 Kudos
Message 4 of 9
(3,353 Views)

 

Ok but I am unsure of how to run that sequence then. If data feeds into 'string subset', my output is a subset string. I compare the subset strings. If the subset string meets the A1 condition it goes to the A1 array. But at this point how do I send the original string to the A1 array and not the subset string?

0 Kudos
Message 5 of 9
(3,347 Views)
Solution
Accepted by lolasue

With a wire, like this

stringer.png

Message 6 of 9
(3,339 Views)

Thanks Daik, I understand your VI. I'm new to Labview and couldnt get my head around how to solve the problem.

0 Kudos
Message 7 of 9
(3,333 Views)

One other question: My data is coming in in Hex format ie 41 32 20 33 33 35 33 but comes in looking like this  41322033333533. Does labview consider 4132 as the first 4 or first 2 elements in the string?

0 Kudos
Message 8 of 9
(3,331 Views)
Solution
Accepted by lolasue

@lolasue wrote:

but comes in looking like this  41322033333533. Does labview consider 4132 as the first 4 or first 2 elements in the string?


That looks like what I call "ASCII Hex".  You have 2 ASCII characters to represent a single byte of data.  It is twice the storage, but is easily human readable.  But if the string is actually "41322033333533", the first four characters is "4132".


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 9 of 9
(3,290 Views)