[Lazarus] tail on windows
dmitry boyarintsev
skalogryz.lists at gmail.com
Sat Jul 17 15:59:07 CEST 2010
program tail;
{$mode objfpc}{$H+}
uses
Classes, Math;
var
names : TStringList;
lines : TStringList;
linescount : Integer;
l, err : Integer;
i, j : integer;
begin
names:=TStringList.Create;
linescount:=20;
i:=1;
while i<=Paramcount do begin
if lowercase(ParamStr(i))='-n' then begin
Val(ParamStr(i+1), l, err);
if err=0 then linescount:=l;
inc(i);
end else
names.Add(ParamStr(i));
inc(i);
end;
lines:=TStringList.Create;
for i:=0 to names.Count-1 do begin
lines.Clear;
try
lines.LoadFromFile(names[i]);
for j:=Max(0, lines.Count-linescount) to lines.Count-1 do
writeln(lines[j]);
except
end;
end;
lines.Free;
names.Free;
end.
More information about the Lazarus
mailing list