How are you reading in your external files -- as a series of lines, or as a 
series of disk bufferfuls?

Either way, you're going to have to do some comparisons.

If you're reading the input files as lines --
See if you have an empty line (just CRLF, probably comes through as "") on 
each read.  If so, tally up the number of consecutive blank lines.  When you 
get to a non-empty line, see how many blank lines you have pending, and if 
it's 4, discard them; if it isn't 4, put that many blank lines into your 
memo buffer.

If you're reading bufferfuls at a time --
Worry that the CRLFCRLFCRLFCRLF string may cross buffer boundaries!  Set up 
a memory area with an (initially empty) 8-character preamble followed by a 
bunch of buffers, making one long string.  Read the buffers.  Search for the 
offending string.  If you find it. snip it out.  Grab the last 8 characters 
from the buffers, and exclude them.  Process the buffers.  Place the 
reserved 8 characters into the preamble.  Read some more buffers.  Search. 
Etc, until EOF.

Another approach ... let the blank lines go into the memo, then search 
through the memo text for appearances of 4 consecutive blank lines, and 
delete those lines.

Does that give you some ideas?

If you need sample code, please let me know which approach you are using.

Rainer



----- Original Message ----- 
From: "Gordon Waters" <[EMAIL PROTECTED]>
To: "Borland's Delphi Discussion List" <[email protected]>
Sent: Monday, March 20, 2006 8:03 PM
Subject: Formatting Text Files


> Hi Delphi Fans,
>
> I am trying to format a series of text files and combined them in to one 
> large file.
>
> My issue is that my input text files are generated by an external system, 
> and this is putting 4 blank lines through out  the text file, what I am 
> trying to do is to remove these 4 blank lines.(and only the 4 blank lines) 
> from the files.
>
> I am currently reading the input files from disk, and appending them to a 
> memo, I then save this memo back to disk with a new name.
>
> So what I am asking is what is a easy way to detect 4 x CR LF in a row and 
> skip appending these to my memo.
>
> Thanks
>
> Gordon.
>
>
>
>
>
>
>
>
>
>
> 

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to