[fpc-pascal] redirecting stdout
    Sven Barth 
    pascaldragon at googlemail.com
       
    Sun Jul 18 13:28:42 CEST 2010
    
    
  
Hi!
You can use WriteStr to "Writeln" to a String (needs 2.4.0 and above).
Example:
var
   s: String;
begin
   WriteStr(s, 'Hello World');
end;
Also you can try unit StreamIO (in fcl-base) which allows you to use 
Streams as TextFiles (you can also look at it to learn how to implement 
your own text driver).
Example:
var
   f: TextFile;
   s: TStringStream;
begin
   s := TStringStream.Create;
   AssignStream(f, s);
   Rewrite(f);
   Writeln(f, 'Hello World');
   CloseFile(f);
   s.Free;
end.
Regards,
Sven
    
    
More information about the fpc-pascal
mailing list