[fpc-pascal] Creating text files with TFileStream

Gerard N/A gerardusmercator at gmail.com
Fri Oct 23 12:30:58 CEST 2009


On Fri, Oct 23, 2009 at 12:21 PM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:

> I can view the resulting output.txt file with Midnight Commander
> (Linux console file manager), but if I try and open that file with
> Gnome gEdit or Lazarus IDE, it says the file does not look like a text
> file and refuses to open it. :-(

var
  AOut: TFileStream;
  s: String;
begin
  s:= '1234';
  AOut:= TFileStream.Create('C:\temp\aa.txt',fmCreate or fmOpenWrite);
  AOut.WriteBuffer(s[1], length(s));
  AOut.Free;

Strange, that works for me under Windows. I get a 4 byte text file
containing '1234'.

Regards,


Gerard.



More information about the fpc-pascal mailing list