BUG: TFileStream ?

edited September 2004 in FastScript
This should run as is, shouldn't it?

Stepping through source Params[0] is assigned,
But returns an empty 'buffer'
(note: c:\22.txt is a file with a single line of text)

==============
var
fs : TFileSTream;
s,buffer : String;
count,res:longint;

begin
fs := TFileStream.Create('c:\22.txt',fmOpenRead);
count := 1000;
res := fs.Read(Buffer,Count);
showmessage(buffer);
fs.free;
end.
==============

Your thoughts?
Brian

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 12:56AM
    Hi Brian
    I'm not fs person
    but i would expect that since showmessage requires a string you can't pass
    the buffer to it directly. probably have to write characters in buffer to a string. ;)

  • edited September 2004
    I figured it out, finally....

    The source code (fs_iclassesrtti.pas) defines the buffer wrong, should be 'var' buffer.

    with AddClass(TStream, 'TObject') do
    begin
    AddMethod('function Read(var Buffer: string; Count: Longint): Longint', CallMethod);

    Then it works fine.

Leave a Comment