[fpc-pascal] Customizing tply

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri Dec 10 10:00:34 CET 2004



On Fri, 10 Dec 2004, Michalis Kamburelis wrote:

> Hi,
>
> I'm attaching my unit TextReader, it
>
> - implements TTextReader class (that is able to read from any TStream
> class using simple Readln and Eof methods) and
>
> - initializes/finalizes some variables to treat standard input/output
> like a TStream classes (or, only in case of standard input, like a
> TTextReader class).

Actually, do you think you could extend this and
create a bridge between streams and text files ?

I mean 2 calls like

First: Text->Stream.

Var
  f : Text;
  S : TSTream;

begin
  AssignTextStream(F,S);
  Rewrite(F);
  Writeln(F,'Something'); // Writes actually to stream S.
  Close(F);
end.

Second: Stream->Text.

Var
  f : Text;
  S : TSTream;
  L : TStringList;

begin
  Assign(F,'File.txt');
  Rewrite(F);
  Writeln(F,'Following lines written to stream:');
  S:=TSomeStream.Create(F);
  L.SaveToStream(S);
  S.Free;
  Close(F);
end;

The second will be probably less used, but the first one may be quite
useful.

Michael.




More information about the fpc-pascal mailing list