Parse RTF or Text Control into several lines including spaces


Author
Message
Michael Reese
Michael Reese
StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
I'm need to parse a text control or Rtf control into several lines. I plan populate an OBX segment for transcriptions. I have the code for building the actual HL7 message. Just need some help on the parsing logic.



Thanks



Michael
Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I am not quite following what you are trying to do. Are you wanting to take the OBX record, break it up into multiple lines then throw it into a text or RTF control? Or do you have a text or RTF control populated with the OBX record and want to extract it out?
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Are you just looking to parse a textfield (or RTF stored as text) into component lines?



Dim MyStringArray as String() = MyBO.MyTextfield.Split(New String() {Chr(13)}, StringSplitOptions.RemoveEmptyEntries)




Michael Reese
Michael Reese
StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
Thanks guys,



I have a text or RTF. I want to extract the text and populate multiple OBX segments with each line (including blank spaces). I have been extracting except that I get bit of a formatting mess like most of the paragrah in one OBX.



not pretty.



Michael
Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, I have lived in the realm of EDI interfaces for a good long while now and this can be a really deep topic in regards to EDI parsing. However, if you are just trying to get the line breaks, then Charles suggestion should work just fine.
Michael Reese
Michael Reese
StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
Ok, thank,



Yeah, My message is generating but I need to clean it up.



Thanks Guys!





MSH|^~\&|Some Sending APP|Sending Facility|EHTESTER2005|SLU|20100308||^MDM^T10|E66F6810E8ED4304AD6F417F561906AE|

EVN|MDM|

PID|1|23455|23455||Smith^Joe ||19560806|M|Joey||10 Wiillington Drive^^Roselle^NJ^07203-1873|USA|(909) 555-2344|(908) 552-1234||S||23455|141-52-3122|

PV1|1|O|ENDO - DOB 2||||SILALA1^SILVERBERG^ALAN^B||||||||||||1|||||||||||||||||||||||||20100306|

TXA|1|PN||20100308|SILALA1^SILVERBERG^ALAN^B^^^^^^^^^|||||SILALA1^SILVERBERG^ALAN^B^^^^^^^^^|001^Test^Test^^^^|^^10821954|^^10821954||||AV|

OBX|1|TX|||All the world's a stage, and all the men and women merely players; they have their exits and their entrances, and one man in his time plays many parts, his acts being seven ages.|

OBX|2|TX|||

|

OBX|3|TX|||

To be, or not to be, that is the question: whether 'tis nobler in the mind to suffer the slings and arrows of outrageous fortune, or to take arms against a sea of troubles and by opposing end them. To die-to sleep, no more; and by a sleep to say we end the heart-ache and the thousand natural shocks that flesh is heir to: 'tis a consummation devoutly to be wish'd. To die, to sleep; to sleep, perchance to dream-ay, there's the rub: for in that sleep of death what dreams may come, when we have shuffled off this mortal coil, must give us pause-there's the respect that makes calamity of so long life. For who would bear the whips and scorns of time, th'oppressor's wrong, the proud man's contumely, the pangs of dispriz'd love, the law's delay, the insolence of office, and the spurns that patient merit of th'unworthy takes, when he himself might his quietus make with a bare bodkin? Who would fardels bear, to grunt and sweat under a weary life, but that the dread of something after death, the undiscovere'd country, from whose bourn no traveller returns, puzzles the will, and makes us rather bear those ills we have than fly to others that we know not of? Thus conscience does make cowards of us all, and thus the native hue of resolution is sicklied o'er with the pale cast of thought, and enterprises of great pitch and moment with this regard their currents turn awry and lose the name of action. |

OBX|4|TX|||

|

OBX|5|TX|||

Shakespeare!|

OBX|6|TX|||

Shakespeare.|

OBX|7|TX|||

Shakespeare?|
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Be aware the .Split() thing has a lot of flexibility.



Should your example yield 7 lines or is there a fixed length to the line and you want to slice it into even pieces?

Michael Reese
Michael Reese
StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)StrataFrame User (299 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
I need to see the lines and and breaks and spaces between lines. Do you have a code example?



Thanks
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Not sure what you mean by "the lines and breaks and spaces between the lines."



The same you posted is hard to decipher because it wraps and we don't know where the lines break. What is the breaking char? Chr(10) chr(13) or a combination? Are there blank lines? What determines where a line begins and ends?



If you can give some very specific answers about the structure parsing it will be pretty easy.



( see my previous question - in the example you posted, how many lines would that break into? )

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Stretching out your sample on my big monitor it seems to be just a delimited file using a pipe seperator. What happens if you try the example of the split() I showed you? If that doesn't work try it with a combination of Chr(13) and chr(10)



You should end up with a string array with one line per item.



Hard to tell how it is structured from the sample but there should be some rules as to where lines break.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search