BCB Mailing List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BCB] Access comma delineated data in TDBMEMO field in Database withou t using strtok
Len Richter (email len@nospam.campbellsci.ca) said:
"I have a database with a memo field with comma delineated data. I would
like to know how to access the individual strings[] and count value. It
seems you can not use the TMemo methods and properties on TDBMEMO. I have
to load the whole memo field as one big string and use strok (see below).
Is there a better way? Possibly using AnsiString function?"
I also use a memo field to store multiple delineated data which I grab
and place in various edit or memo boxes on a special form (there is a
reason why I do this instead of creating unique fields in my database).
Since I process the data before I let a user edit or view the form, I
made the TDBMEMO control invisible, made sure that the width of the
TDBMEMO control was larger than the longest anticipated line and used
the ....->Lines->Strings[x] method to access the data. This eliminated
the need to delineate the data since a linefeed served that purpose. In
my case any data beginning with ...->Lines->Strings[4] was placed in a
TMEMO control and I have used various methods to get this data (the
...->Strings[x] and GetTextBuf methods). The only problem I have had
with this method was to make sure the control was wide enough to keep my
data on a single line; narrow controls usually insert a new linefeed and
throws off the count. This works well for me and uses very little
programming to accomplish a desired task.
// Add text to the appropriate edit boxes
Dlg_From->Text = Dlg_DbMemo->Lines->Strings[0];
Dlg_To->Text = Dlg_DbMemo->Lines->Strings[1];
Dlg_Kind->Text = Dlg_DbMemo->Lines->Strings[2];
Dlg_Agency->Text = Dlg_DbMemo->Lines->Strings[3];
.....
.....
John McCoy
W Komornicki's Home Page |
Main Index |
Thread Index