[fpc-pascal] Creating text files with TFileStream

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Oct 23 12:15:24 CEST 2009


2009/10/23 Gerard N/A <gerardusmercator at gmail.com>:
>
> Could it be that the length indicator bytes of the string are written
> to the stream?

Ah, looking at the .WriteAnsiString() implementation, you seem to be
100% correct.

  Procedure TStream.WriteAnsiString (const S : String);
  Var L : Longint;
  begin
    L:=Length(S);
    WriteBuffer (L,SizeOf(L));
    WriteBuffer (Pointer(S)^,L);
  end;


That function is then very deceiving - by doing something extra to
what the method name suggests. Why is the writing of the string length
as a prefix needed?



> Did you try writing with WriteBuffer(Atext[1], length(AText)?

That works exactly like I intended. Thanks Gerard.



-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list