Board index » cppbuilder » Formatting text using StringList

Formatting text using StringList


2007-01-13 04:18:59 AM
cppbuilder51
I am not sure where to start with this.
I have a 1/2 MB txt file that I have to format. I already ran the
file thorugh a parser and removed all the white spaces before and
after every line. But now I have a few more things to do and I am
a bit lost
// This is what the file listings look like
Item: 1 (Ref#:????-??-???.?????.?.?.??)
Reference:
Millions of people in the Texas Panhandle, Oklahoma and eastern
Missouri are being warned that conditions will deteriorate Friday
afternoon, and the storm could spread as far east as Ohio and New
York over the Martin Luther King Jr. holiday weekend.
CheckState:
Freezing rain hit Oklahoma today, the start of what forecasters say
could be a brutal ice storm. Millions of people in the Texas Panhandle,
Oklahoma and eastern Missouri are being warned that conditions will
deteriorate this afternoon and the storm could spread as far east as
Ohio and New York over the Martin Luther King Jr. holiday weekend.
Everything is very standard with the listings, some lines may be more
and some may be less to make up the reference or the checkstate. But
I have to format the entire file in the following way.
Quote
>Line: Item: 1 (Ref#:????-??-???.?????.?.?.??)
Need: '1'
Quote
>Reference:
>Millions of people in the Texas Panhandle, Oklahoma and eastern
Need: Millions of people in the Texas Panhandle, Oklahoma and eastern
Missouri are being warned that conditions will deteriorate Friday
afternoon, and the storm could spread as far east as Ohio and New
York over the Martin Luther King Jr. holiday weekend.
(entire line has to be concatenated, no carriage returns)
The same applies for the 'CheckState' fields.
The end result will be:
1. Millions of people in the Texas Panhandle, Oklahoma and eastern (plus the rest of the line)
Freezing rain hit Oklahoma today, the start of what forecasters say (plus the rest of the line)
The format of the file to be read does not seem to bad, the file must have
no blank lines at all. I feel like I can parse the following line
"Item: 1 (Ref#:????-??-???.?????.?.?.??)" to get the record number out of it,
but to search for and concat the other lines, that one is hard.
File Format:
(rec#. reference)
(checkstate)
Can someone help me out here?
Thanks
Randy
 
 

Re:Formatting text using StringList

"Randy Wade" < XXXX@XXXXX.COM >wrote:
Quote

[...] I feel like I can parse the following line
"Item: 1 (Ref#:????-??-???.?????.?.?.??)" to get the record
number out of it, but to search for and concat the other
lines, that one is hard.
In what way? If you know where one starts, certainly you know
where the prior ends. Once you have those 2 points you can
easily form a single AnsiString and then use AnsiString methods
to remove cr/lf pairs or white space.
Quote
[...] Can someone help me out here?
It's not clear what you are asking for.
~ JD