GetStringFromStream
Return to Introduction  Previous page  Next page
Unit
acUtils  

Declaration
function GetStringFromStream: String;  

Description
The GetStringFromStream function retrieves the string from current position of stream. It determines the size of string by first 4 bytes read from stream. This function should be used to get the string, if the string was put to stream with PutStringToStream procedure.  

Original code
function GetStringFromStream(Stream: TStream): String;  
var  
  Len: DWord;  
begin  
  with Stream do  
   try  
     Read(Len, SizeOf(Len));  
     { check whether the stream really contain the line with such length }  
     if Size - Position >= Len then  
      begin  
       SetLength(Result, Len);  
       Read(Result[1], Len);  
      end  
     else Result := '';  
   except  
   end;  
end;  

See also
GetStringFromStream function.