It should be

  X := TextFile.Read(Buffer^,1024);

(see the ^).

Cheers,
Carl

-----Original Message-----
From: Patrick Dunford [mailto:[EMAIL PROTECTED]]
Sent: Friday, 30 June 2000 3:25 PM
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Question


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.
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to