<p>Am 21.07.2014 10:29 schrieb "LacaK" <<a href="mailto:lacak@zoznam.sk">lacak@zoznam.sk</a>>:<br>
><br>
> Hi,<br>
> When I work with f.e. TFileStream I need often write string into stream.<br>
> Now I use:<br>
> Stream1.WriteBuffer(s[1], length(s));<br>
><br>
> I think, that for convenience it will be useful having something like:<br>
> procedure TStream.WriteString(const s: string);<br>
> begin<br>
> WriteBuffer(s[1], length(s)*sizeof(char);<br>
> end;<br>
><br>
> In FPC we now have for user convenience also WriteByte, WriteWord, WriteQWord (which all calls WriteBuffer)<br>
> and Delphi has lot of overloaded WriteData (but none of them takes as parameter string):<br>
> <a href="http://docwiki.embarcadero.com/Libraries/XE3/en/System.Classes.TStream.WriteData">http://docwiki.embarcadero.com/Libraries/XE3/en/System.Classes.TStream.WriteData</a><br>
><br>
> Do you think, that something similar can be added also in FPC ?</p>
<p>There is already a WriteAnsiString ( <a href="http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html">http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html</a> ) with the difference that it also writes out the length. Adding an additional overload (especially with a name like WriteString) would IMHO be confusing because of this.</p>
<p>Nothing stops you though from writing a class helper that adds a WriteString method to TStream.</p>
<p>Regards,<br>
Sven</p>