OK this is my code so far
var
FSize : LongInt;
TextFile : TFileStream;
Buffer : PChar;
var X:longint;
begin
GetMem(Buffer,1024);
try
TextFile := TFileStream.Create(ParamStr(1),fmOpenRead or
fmShareDenyNone);
FSize := TextFile.Size;
ShowMessage(IntToStr(FSize)); {
if (FSize > 1024) then begin
TextFile.Seek(-1024,soFromEnd);
end; }
LogField.Lines.Clear;
X := TextFile.Read(Buffer,1024);
ShowMessage(IntToStr(X));
LogField.Text := String(Buffer);
TextFile.Free;
except
LogField.Lines.Add('Error opening file');
end;
end;
Except that the file length is something like 19576 and the value of X comes
as 0. This is with no seeking so it should read from the start.
How do you define Buffer since it obviously doesn't like the declaration.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of [EMAIL PROTECTED]
> Sent: Friday, 30 June 2000 14:54
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Question
>
>
>
> Something along the lines of...
>
> var
> lStream: TFileStream;
>
> begin
> lStream := TFileStream.Create('The Filename', fmOpenRead);
> try
> if lStream.Size > 1024 then
> begin
> lStream.Seek(-1024, foFromEnd);
> < do what ever here >
> end;
> finally
> lstream.free;
> end;
>
> JED
>
>
> (Embedded
> image moved [EMAIL PROTECTED]
> to file: 30/06/2000 12:48
> pic01169.pcx)
>
>
>
>
> Please respond to [EMAIL PROTECTED]
>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> cc:
> Subject: [DUG]: Question
>
>
> Let's say I need to see the last 1024 characters in a text file. Would I
> use
> a file stream to access it? How?
>
> ============================================
> Patrick Dunford, Christchurch, NZ
> EnzedRailWeb Sites
> http://www.trainweb.org/enzedrail/web/
>
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz