Hi!
Does anybody know how to write a Pascal app that would remove blank lines from a text file.
function RemoveBlankLines(OldFile: string): string;
var fi,fo: Text;
s,NewFile: string;
n: integer;
begin
result:=EmptyStr;
if FileExists(OldFile) then
begin
//rename old file .bak,
n:=Length(OldFile);
while (n>1) and (OldFile[n]<>'.') do Dec(n);
n:=Length(OldFile)-n;
NewFile:=Copy(OldFile,1,Length(OldFile)-n)+'bak';
RenameFile(OldFile,NewFile);
s:=NewFile; NewFile:=OldFile; OldFile:=s;
//massing with file names
AssignFile(fi,OldFile);
AssignFile(fo,NewFile);
Reset(fi);
ReWrite(fo);
while not EOF(fi) do
begin
Readln(fi,s);
if Length(Trim(s))>0 then
WriteLn(fo,s) else
RemoveBlankLines('OldFile.txt');
end;
CloseFile(fo);
CloseFile(fi);
here's my try but it doesn't f*** work.
It's got to be a Pascal Console app.
I'd appreciate if somebody could show me how to solve the darn problem.