PDA

Click to See Complete Forum and Search --> : Parse serial data


cmf
Jan 9th, 2000, 01:16 AM
I have the following data streaming in from a serial device:

"Wxxx Fxxxxxxxx|ID S xxxxxx|ID E xxxxxx|Wxxx Fxxxxxxxx"

I need to parse it so that when the code see's the "|", it will do a carriage return and the data streaming in from the serial device will look like this:

Wxxx Fxxxxxxxx
ID S xxxxxx
ID E xxxxxx
Wxxx Fxxxxxxxx

I appreciate any help or code snippets you can offer. this is my first attempt at programming!

Regards,

Michael

Clunietp
Jan 9th, 2000, 01:20 AM
Assuming you are using VB6:

Dim str As String
Dim newstr As String


str = "Wxxx Fxxxxxxxx|ID S xxxxxx|ID E xxxxxx|Wxxx Fxxxxxxxx"

newstr = Replace(str, "|", vbCrLf)

MsgBox newstr


Tom

Jan 9th, 2000, 01:21 AM
or you could do this if you need to edit the data rapidly

dim Mystring$ 'contains serial data
dim MyArray() 'variant array
dim i% 'for...next counter

myarray = split(mystring, "|") 'cuts up the 'data into segments between the pipe 'characters "|".

for i = 0 to ubound(myarray)
me.print myarray(i)
next i

wossnamex@talk21.com

[This message has been edited by wossname (edited 01-09-2000).]

cmf
Jan 9th, 2000, 03:07 AM
I need to add that the data stream coming in from the serial port will be in random order, and will always be broken up by "|".
I also want to display this data in a text box....


thank you for your help!