LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to break a string!!

Hii everyone,
I'm using Visa protocol to get data inthe form of text string from serial port, but facing problems with how to break that data. My data is coming in this format:
x234y236x233y23x238y34.....
This actually says that (x234y236)present X position is 234 and Y position is 236 and so on. I wish to break this string and show value 234 under X indicator and value 236 under Y indicator. Can anyone help how can I use Match pattern pallette or any other pallete to achieve my goal?
Looking for help,
Regards
0 Kudos
Message 1 of 34
(6,001 Views)
Hi,

Look at the attached code here. This scans the string and fills up arrays of x and y numerics.

Hope that helps.

-Tim
0 Kudos
Message 2 of 34
(5,991 Views)
Oops,I'm working on Labview 8.0Smiley Sad
Can you please attach the code in 8.0
0 Kudos
Message 3 of 34
(5,989 Views)
Hi,

Sure, here is the code.

Tim
0 Kudos
Message 4 of 34
(5,986 Views)
There are many ways to do this. Here are two possibilities (LabVIEW 8.0). 🙂
 
(Sorry, I spend only a few minutes on this, so there are probably bugs. Modify as needed.)
Message 5 of 34
(5,984 Views)
Hi thanks for the code,
It's working great!!
But I wanna convert this this text array into integer so that I can perform some calculations over it. Can you suggest me what should I do further to convert this text into corresponding decimal numbers. .i.e   "1234" string as integer 1234.

0 Kudos
Message 6 of 34
(5,946 Views)
Hi,

If you look at the code that I posted, it already converts the strings to numerics for you. The data is in the form of a numeric array. But converting text to numbers is easily done by using the string to numeric vis inside of labview under the string >> string/number conversion pallette.

-Tim
0 Kudos
Message 7 of 34
(5,940 Views)
Also note that the VIs Tim refered you to are polymorphic. What that means is that if you wire a 2D array of strings up to one you get out a 2D array of numbers. No other manipulation required.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 34
(5,923 Views)
Yeah, that's correct!
But Oops, New bug has arrived.
As you know Im scanning data as x23y34x76y345x333..... and my data string is like x23y34 as I've written above.
But I'm loosing on data. Sometimes instead of scanning 23 under x it scans 23 and under y it scans zero and in the next iteration when the string isread the indicator reads the latter part i.e. 23y34 like that. I mean it gets shady some times.

Can't I develop something which scans for a particular pattern, store it in something like buffer string and than process that buffer to separate the data into their individual arrays??

I can modify my microcontroller code to send a footer at the data string like, if you want:
x23y34ex25y45e..... where "e" signifies that first iteration finished so that buffer can be complete??
0 Kudos
Message 9 of 34
(5,900 Views)
Actually, that's exactly what one of the examples that was posted does, it divides the string up based on the X label and then processes the resulting array of values to split each one at the Y label.

Post the VI that you are using and an example of the data string that demonstrates the problem.

Mike...

Message Edited by mikeporter on 06-29-2007 08:16 PM


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 34
(5,892 Views)