was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

53 Visitors Online


 
...einige TStream Hilfs-Funktionen verwenden?
Autor: Thomas Mueller
Homepage: http://www.s2h.cx
[ Tip ausdrucken ]  

Tip Bewertung (5):  
     


{
 These are three utility functions to write strings to a TStream.
 Nothing fancy, but I just ended up coding this repeatedly so
 I made these functions. }

{
 Hier sind einige TStreaam Hilfsfunktionen um strings
 in einen TStream zu schreiben.
}


unit ClassUtils;

interface

uses
  
SysUtils,
  Classes;

{: Write a string to the stream
   @param Stream is the TStream to write to.
   @param s is the string to write
   @returns the number of bytes written. }
function Writestring(_Stream: TStream; const _s: string): Integer;

{: Write a string to the stream appending CRLF
   @param Stream is the TStream to write to.
   @param s is the string to write
   @returns the number of bytes written. }
function WritestringLn(_Stream: TStream; const _s: string): Integer;

{: Write formatted data to the stream appending CRLF
   @param Stream is the TStream to write to.
   @param Format is a format string as used in sysutils.format
   @param Args is an array of const as used in sysutils.format
   @returns the number of bytes written. }
function WriteFmtLn(_Stream: TStream; const _Format: string;
  _Args: array of const): Integer;

implementation

function 
Writestring(_Stream: TStream; const _s: string): Integer;
begin
  
Result := _Stream.Write(PChar(_s)^, Length(_s));
end;

function WritestringLn(_Stream: TStream; const _s: string): Integer;
begin
  
Result := Writestring(_Stream, _s);
  Result := Result + Writestring(_Stream, #13#10);
end;

function WriteFmtLn(_Stream: TStream; const _Format: string;
  _Args: array of const): Integer;
begin
  
Result := WritestringLn(_Stream, Format(_Format, _Args));
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners