Board index » delphi » Help with TStream and Run-time Error 210

Help with TStream and Run-time Error 210

I am having trouble using streams.  I need to store
the contents of a memo field in memory for a while.
Unfortunately, I get a Run-time error 210 when
I execute my code.  This error is useless to me, because
I can't find any help for run-time errors in the
online help facilities.  The following code is just
to demonstrate the error.  But if there is a better way
to store memo fields in memory dynamically, I'd love to
hear it.

To duplicate the error:  
add 2 memo fields to a form.  On a button_click, try the
following code:
var
  stream : TStream;
begin
  stream := TStream.create;
  memo1.lines.savetostream(stream);
  memo2.lines.loadfromstream(stream);
  stream.free;
end;

Thanks in advance for any help,
Eric J. Lannert
Northwestern University, Evanston, IL.   USA
lann...@ils.nwu.edu

 

Re:Help with TStream and Run-time Error 210


Hi,

Maybe the following will solve the problem,

Quote
>var
>  stream : TStream;

  Stream : TMemoryStream;

Quote
>begin
>  stream := TStream.create;

  stream := TMemoryStream.Create;

Quote
>  memo1.lines.savetostream(stream);

{ Reset position of stream to zero }
  Stream.Position := 0;

Quote
>  memo2.lines.loadfromstream(stream);
>  stream.free;
>end;

I'm not sure if it works but you also could try to use Assign method to copy
one memo field to another:

memo2.lines.assign(memo1.lines);

I've never done anything with memo so again I'm not sure the above would work.

Hope this helps a little bit,

Josha Munnik.

_________________________________________________________________
I-ViSaGE               |  "The guide says there is an art to
Josha Munnik           |  flying," said Ford, "or rather a knack.
mun...@cs.utwente.nl   |  The knack lies in learning how to throw
tel: +31-(0)74.502953  |  yourself to the ground and miss."
fax: +31-(0)10.4769477 |  
_______________________|  (The Hitchhikers guide to the Galaxy)

Other Threads