06-01-2016 08:38 AM
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.
Solved! Go to Solution.
06-01-2016 08:47 AM
Try using the "string subset" function to get the first 4 digits of the data and compare that
06-01-2016 08:50 AM
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?
06-01-2016 08:51 AM
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.
06-01-2016 09:01 AM - edited 06-01-2016 09:02 AM
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?
06-01-2016 09:04 AM
With a wire, like this
06-01-2016 09:08 AM
Thanks Daik, I understand your VI. I'm new to Labview and couldnt get my head around how to solve the problem.
06-01-2016 09:11 AM
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?
06-01-2016 10:53 AM
@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".