Ver Mensaje Individual
  #2  
Antiguo 24-04-2007
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Prueba este código:

Código Delphi [-]
{
  Comprime líneas en blanco

  El procedimiento lee el archivo InputFileName, reduce grupos de líneas
  consecutivas en blanco a una sola y escribe el texto transformado en
  OutputFileName.
}
procedure CompressBlankLines(InputFileName, OutputFileName: String);
var
  InputFile, OutputFile: TextFile;
  Line: String;

begin
  AssignFile(InputFile, InputFileName);
  Reset(InputFile);

  AssignFile(OutputFile, OutputFileName);
  Rewrite(OutputFile);

  while not Eof(InputFile) do
  begin
    ReadLn(InputFile, Line);

    if Trim(Line) = '' then
    begin
      repeat
        ReadLn(InputFile, Line);
      until Trim(Line) <> '';

      WriteLn(OutputFile, '');
    end;

    WriteLn(OutputFile, Line);
  end;

  CloseFile(InputFile);
  CloseFile(OutputFile);
end;

No funciona sobre un memo, sino directamente sobre el archivo en disco, pero creo que te haces la idea.

// Saludos
Responder Con Cita