Board index » delphi » Copying TMemoFields

Copying TMemoFields

On Fri, 16 Feb 1996 13:40:00 GMT, sc...@chtics.demon.co.uk (Scott

Quote
Paterson) wrote:
>Can someone tell me how I transfer the contents of a Memo field (Dbase
>File ) into another memofield.
>I have been struggling with this for ages and have got no where fast
>with it.

>Please help me !

I think you can use the Memo1.Assign(Memo2); not sure since I don't
have Delphi up and running, but its worth a shot.
 

Re:Copying TMemoFields


On Fri, 16 Feb 1996 13:40:00 GMT, sc...@chtics.demon.co.uk (Scott Paterson)
wrote:

Quote
>Can someone tell me how I transfer the contents of a Memo field (Dbase
>File ) into another memofield.
>I have been struggling with this for ages and have got no where fast
>with it.

Couple of different ways to do this. One way is to use the Assign method of
the TMemoField component. For example:

  Table1Notes.Assign(Table2MemoFld);

Or, if you do not define TField components for fields in your application:

TMemoField(Table1.FieldByName('Notes')).Assign(TMemoField(Table2.FieldByName('MemoFld'));

Another method would be to use TBlobStream objects. The Read method of this
object could be used to copy the contents of a memo field into a PChar (or
equivalent) variable. The Write method to copy the contents of a PChar
variable to a memo field. The fields could be in the same or different
tables. They could also be the same field in the same table, but with a
change in the record pointer between reading and writing (requiring a
single TBlobStream object be used, but freed and recreated between
records).

**************************************************************************
Steve Koterski                  "Results! Why, man, I have gotten a lot of
Product Group Manager           results. I know several thousand things
Delphi Technical Support        that won't work."
Borland International, Inc.                    -- Thomas Edison, 1847-1931

Re:Copying TMemoFields


If you are using a DBMemo component, you can references the Lines
Property of your two memo objects, as in:

...
  for i := 0 to DBMemo1.Lines.Count - 1 do
    DBMemo2.Lines.Add(DBMemo1.Lines[i]);
...

Hope this helps.

--
Regards,

Ray Hope
Autopia Computer Products Inc.

Other Threads