﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <description><![CDATA[Comments for How to move a string into a TMemoryStream or TFileStream.]]></description>
    <title><![CDATA[Comments for How to move a string into a TMemoryStream or TFileStream.]]></title>
    <link>http://edn.embarcadero.com/article/26416</link>
    <!-- source: http://edn.embarcadero.com/article/26416/feed-->
    <dc:date>2009-11-08T01:13:26-08:00</dc:date>
    <item>
      <description><![CDATA[The length of a string is needed to know how much we must allocate a string size .... Thanks for the discussion guys ... And special thanks for the program you made Ralph Friedman ... ]]></description>
      <title><![CDATA[re: How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Hendra  Suryadarma)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27587</guid>
      <dc:date>2001-01-16T17:01:54-08:00</dc:date>
      <pubDate>2001-01-16T17:01:54-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <item>
      <description><![CDATA[In that case, there is no difference between:Pointer(Msg)^andMsg[1]it will still get to the stream. With the 2nd the code will be much easier to decipher by 85% of Delphi developers. The notation doesn't change the contents or the output.]]></description>
      <title><![CDATA[re: How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Ralph Friedman)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27334</guid>
      <dc:date>2000-12-15T08:34:15-08:00</dc:date>
      <pubDate>2000-12-15T08:34:15-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <item>
      <description><![CDATA[For me, the original 'simplistic' example was exactly therequired solution e.g. you want to send a string's contentsto an application on another computer that expectsthe string length to be expressed as a 4-ascii- character prefix - say '0019This is the message' - youdefinitely don't want any Delphi-specific, or even worse,Delphi-version-specific stuff in there - so the DelphiPointer(Msg)^ or Msg[1] is what's required.I'm using it in a real-world application.]]></description>
      <title><![CDATA[How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Iain McCallum)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27332</guid>
      <dc:date>2000-12-15T05:26:28-08:00</dc:date>
      <pubDate>2000-12-15T05:26:28-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <item>
      <description><![CDATA[Whoops! I inadvertently reposted the original. I've corrected that now. The original may have been simplistic, but it was definitely not practical. I added the ability to store the string length. I also used Pascal notation as opposed to the C++ notation that was in the original example]]></description>
      <title><![CDATA[re: How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Ralph Friedman)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27329</guid>
      <dc:date>2000-12-15T01:44:02-08:00</dc:date>
      <pubDate>2000-12-15T01:44:02-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <item>
      <description><![CDATA[The method presented is fine in the unlikely event that one is storing a singe string to a stream. The following rewrite takes into consideration the possibility that the goal is to store more than one string:procedure TForm1.Button1Click(Sender: TObject);var  lng:          integer;  MemoryStream: TMemoryStream;  SourceString: string;begin  SourceString := 'Hello, how are you doing today?';  MemoryStream := TMemoryStream.Create;  try    // Write the length of the string to the stream:    lng := Length(SourceString);    MemoryStream.WriteBuffer(lng, SizeOf(lng));    // Write the string to the stream. We want to write from SourceString's    // data, starting at a pointer to SourceString (this returns a pointer to    // the first character), dereferenced (this gives the actual character).    MemoryStream.WriteBuffer(SourceString[1], Length(SourceString));    // Go back to the start of the stream    MemoryStream.Position := 0;    // Read it back in to make sure it worked.    // Set the length, so we have space to read into    MemoryStream.ReadBuffer(lng, SizeOf(lng);    SetLength(SourceString, lng);    MemoryStream.ReadBuffer(SourceString[1], lng);    Caption := SourceString;  finally    MemoryStream.Free;  end;end;]]></description>
      <title><![CDATA[How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Ralph Friedman)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27323</guid>
      <dc:date>2000-12-15T01:42:21-08:00</dc:date>
      <pubDate>2000-12-15T01:42:21-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <item>
      <description><![CDATA[Ralph - what was the change you made? - the example was made to be highly simplistic.]]></description>
      <title><![CDATA[re: How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Corbin Dunn)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27327</guid>
      <dc:date>2000-12-14T15:50:04-08:00</dc:date>
      <pubDate>2000-12-14T15:50:04-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <item>
      <description><![CDATA[True...and both ways work fine. I wrote this article due to a support phone call on "how do I do it". I copied it from the VCL...]]></description>
      <title><![CDATA[re: How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Corbin Dunn)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27326</guid>
      <dc:date>2000-12-14T15:44:01-08:00</dc:date>
      <pubDate>2000-12-14T15:44:01-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <item>
      <description><![CDATA[I got this solution from the ObjectPascal newsgroup:MemoryStream.Write(SourceString[1], Length(SourceString));This is more like Delphi - elegant and transparent - less likeC++ - cryptic and opaque !]]></description>
      <title><![CDATA[How to move a string into a TMemoryStream or TFileStream.]]></title>
      <managingEditor>
	 (Iain McCallum)
</managingEditor>
      <guid isPermaLink="true">http://threads.embarcadero.com/threads/threads.exe/view?commentid=27310</guid>
      <dc:date>2000-12-12T22:38:00-08:00</dc:date>
      <pubDate>2000-12-12T22:38:00-08:00</pubDate>
      <source url="http://edn.embarcadero.com/article/26416/feed">Comments for How to move a string into a TMemoryStream or TFileStream.</source>
    </item>
    <generator>Atom 1.0 XSLT Transform v1 (http://atom.geekhood.net)</generator>
  </channel>
</rss>