Board index » delphi » TMemoField.getdata not working????

TMemoField.getdata not working????

Hi,

I have go a problem accessing the data of a TMemoField with the getData
method. Whenever I try to access the data, I get 'operation not
applicable'. I really need that data into a pchar. At this moment I'm
using a workaround with saveToStream using a memorystream, and
converting that into a pchar, but this is not very convenient. Does
anyone have a clue?

This doesn't work:
  p := strAlloc(myMemoField.dataSize);
      {by the way, datasize always returns zero}
  myMemoField.getData(p);
This does work:
  myMemoField.saveToStream(myMemoryStream);

Thanks in advance.
greetz -frank.korpersh...@nni.nl-

(please send me a copy of your answer, don't want to miss it in these
high flow newsgroups.....)

 

Re:TMemoField.getdata not working????


Quote
Frank Korpershoek wrote:

> Hi,

> I have go a problem accessing the data of a TMemoField with the getData
> method. Whenever I try to access the data, I get 'operation not
> applicable'. I really need that data into a pchar. At this moment I'm
> using a workaround with saveToStream using a memorystream, and
> converting that into a pchar, but this is not very convenient. Does
> anyone have a clue?

> This doesn't work:
>   p := strAlloc(myMemoField.dataSize);
>       {by the way, datasize always returns zero}
>   myMemoField.getData(p);
> This does work:
>   myMemoField.saveToStream(myMemoryStream);

> Thanks in advance.
> greetz -frank.korpersh...@nni.nl-

> (please send me a copy of your answer, don't want to miss it in these
> high flow newsgroups.....)

If you are using Delphi 2, you can take advantage of the "big strings"
feature and do TMemo.AsString to access the data. According to
Borland, big strings will support string lengths of "virtually
unlimited size".

If you are in Delphi 1, you have to do something like:
  var textBuf : array[0..100] of char;
      TextBlobStream : TBlobStream;
  ...
  FillChar(textBuf, SizeOf(textBuf), #0);
  TextBlobStream := TBlobStream.Create(TMemo, bmRead);
  TextBlobStream.Read(textBuf, SizeOf(textBuf)-1);
  TextBlobStream.Free;
  ...

Hope this helps!
--
Dale Jablonski

Re:TMemoField.getdata not working????


That was informative, and thanks for answering his question.  Could I
bother you to help me with going the other way?  From an already
establised pchar into a tmemoField of a new record.  How do I tell the BDE
I want to plop some data into a memo field when it defaults size to 1, and
if I use the Tfields editor to set it to 32000, it says "Field not of
expected type"!  Besides, I'd rater only put in the database the 3 or 4
hundred characters I need to save.

TIA

Brandon Smith
Synat...@aol.com

Re:TMemoField.getdata not working????


Quote
> That was informative, and thanks for answering his question.  Could I
> bother you to help me with going the other way?  From an already
> establised pchar into a tmemoField of a new record.  How do I tell the BDE
> I want to plop some data into a memo field when it defaults size to 1, and
> if I use the Tfields editor to set it to 32000, it says "Field not of
> expected type"!  Besides, I'd rater only put in the database the 3 or 4
> hundred characters I need to save.

        That size is not the size you are looking for.. In D2 you can assign large strings to Memo's using
AsString and others...
        In D1, the STREAMS can be quite effective.. (You can use memory stream)

Other Threads