Board index » delphi » Compare tMemoField Contents to Stringlist contents

Compare tMemoField Contents to Stringlist contents

On Thu, 05 Nov 1998 16:30:46 GMT, [email protected] (Ross C.

Quote
Williams) wrote:
>I am trying to compare the contents of a MemoField to an external value. The
>idea is to check to see if the value has changed. I always get a false result;

>The value that comes out does not equal the value that got put in.

>given TMemoField(FieldByName('MyField').Assign(MyStringList);

>How do I check to see if the contents of MyField = MyStringList? This ought to
>be simple, but it looks like it needs to be compared line by line.

//////////////////////////////////////////////////////////////////////////
Steve Koterski                 "What is success in this world? I would say
Technical Publications         it consists of four simple things: to live
INPRISE Corporation            a lot, to love a lot, to laugh a lot, and
http://www.inprise.com/delphi  from it all, to learn a lot."
                                                     -- Richard J. Needham
 

Re:Compare tMemoField Contents to Stringlist contents


On Thu, 05 Nov 1998 16:30:46 GMT, [email protected] (Ross C.

Quote
Williams) wrote:
>I am trying to compare the contents of a MemoField to an external value. The
>idea is to check to see if the value has changed. I always get a false result;

>The value that comes out does not equal the value that got put in.

>given TMemoField(FieldByName('MyField').Assign(MyStringList);

>How do I check to see if the contents of MyField = MyStringList? This ought to
>be simple, but it looks like it needs to be compared line by line.

What you may need to do is extract the data from the TMemoField and the
TStringList into PChar buffers and use one of the null-terminated string
functions to compare the two values.

You can extract the data from a TMemoField or TStringList in a number of
ways. One way would be to create a TMemoryStream and use the SaveToStream
method (available to both the TMemoField and TStringList classes). Once
accessible in a stream, use the stream object's Write method to copy the
data from the stream into a PChar. Once in a PChar buffer, you can use a
function such as AnsiStrComp or AnsiStrIComp to compare the contents of the
two PChar buffers as strings of data.

//////////////////////////////////////////////////////////////////////////
Steve Koterski                 "What is success in this world? I would say
Technical Publications         it consists of four simple things: to live
INPRISE Corporation            a lot, to love a lot, to laugh a lot, and
http://www.inprise.com/delphi  from it all, to learn a lot."
                                                     -- Richard J. Needham

Other Threads