Board index » delphi » Memo "BLOB" fields and Lists

Memo "BLOB" fields and Lists

Can anyone tell me how to read a memo field into a TStringList object? I am
stumped...

FYI, I am using the memo field to store a list of items (similar to an INI
file) and now I want to read that list of settings back into the program.

Any help will be appreciated...
Thanks,
Dan Cumpian
Quality Transportation Services

 

Re:Memo "BLOB" fields and Lists


Use the statement

    MyStringList.Assign(myTable.FieldByName('Memo1'));

Woody

Quote
Dan Cumpian <ir000...@mindspring.com> wrote in message

news:7m5n53$tl1$1@nntp1.atl.mindspring.net...
Can anyone tell me how to read a memo field into a TStringList object? I am
stumped...

FYI, I am using the memo field to store a list of items (similar to an INI
file) and now I want to read that list of settings back into the program.

Any help will be appreciated...
Thanks,
Dan Cumpian
Quality Transportation Services

Re:Memo "BLOB" fields and Lists


Thanks for the help...it seems so obvious now.  Believe it or not, I spent
two hours trying to find the correct solution in the help files. Is there
any place that references properties and methods in a less cryptic format?

Thanks,
Dan Cumpian

Quote
Woody wrote in message <931558602.206...@news.remarQ.com>...
>Use the statement

>    MyStringList.Assign(myTable.FieldByName('Memo1'));

>Woody

>Dan Cumpian <ir000...@mindspring.com> wrote in message
>news:7m5n53$tl1$1@nntp1.atl.mindspring.net...
>Can anyone tell me how to read a memo field into a TStringList object? I am
>stumped...

>FYI, I am using the memo field to store a list of items (similar to an INI
>file) and now I want to read that list of settings back into the program.

>Any help will be appreciated...
>Thanks,
>Dan Cumpian
>Quality Transportation Services

Re:Memo "BLOB" fields and Lists


Woody,

I tried what you suggested and I get "Data type incompatible" error
messages. What is stored in the memo field is a string list that I created.
Perhaps what I really have is a long string separated by a CHR(13)?

Any advice?
Dan

Quote
Woody wrote in message <931558602.206...@news.remarQ.com>...
>Use the statement

>    MyStringList.Assign(myTable.FieldByName('Memo1'));

>Woody

>Dan Cumpian <ir000...@mindspring.com> wrote in message
>news:7m5n53$tl1$1@nntp1.atl.mindspring.net...
>Can anyone tell me how to read a memo field into a TStringList object? I am
>stumped...

>FYI, I am using the memo field to store a list of items (similar to an INI
>file) and now I want to read that list of settings back into the program.

>Any help will be appreciated...
>Thanks,
>Dan Cumpian
>Quality Transportation Services

Re:Memo "BLOB" fields and Lists


Hi !

What about

  MyStringList.text:=MyTable.FieldByName('Memo1').AsString;

?

--

Bjoerge

<<Dan Cumpian skrev i meldingen <7mcref$v1...@nntp5.atl.mindspring.net>...
Woody,

I tried what you suggested and I get "Data type incompatible" error
messages. What is stored in the memo field is a string list that I created.
Perhaps what I really have is a long string separated by a CHR(13)?

Any advice?
Dan

Quote
Woody wrote in message <931558602.206...@news.remarQ.com>...
>Use the statement

>    MyStringList.Assign(myTable.FieldByName('Memo1'));

>Woody

>Dan Cumpian <ir000...@mindspring.com> wrote in message
>news:7m5n53$tl1$1@nntp1.atl.mindspring.net...
>Can anyone tell me how to read a memo field into a TStringList object? I am
>stumped...

>FYI, I am using the memo field to store a list of items (similar to an INI
>file) and now I want to read that list of settings back into the program.

>Any help will be appreciated...
>Thanks,
>Dan Cumpian
>Quality Transportation Services

Re:Memo "BLOB" fields and Lists


It's possible. I use this type of assignment statement all the time to get
memo field contents. You can assign ANY string list such as a TMemo.Lines,
etc. I don't know why it doesn't work for you...

Woody

Quote
Dan Cumpian <ir000...@mindspring.com> wrote in message

news:7mcref$v19$1@nntp5.atl.mindspring.net...
Woody,

I tried what you suggested and I get "Data type incompatible" error
messages. What is stored in the memo field is a string list that I created.
Perhaps what I really have is a long string separated by a CHR(13)?

Any advice?
Dan

Quote
Woody wrote in message <931558602.206...@news.remarQ.com>...
>Use the statement

>    MyStringList.Assign(myTable.FieldByName('Memo1'));

>Woody

>Dan Cumpian <ir000...@mindspring.com> wrote in message
>news:7m5n53$tl1$1@nntp1.atl.mindspring.net...
>Can anyone tell me how to read a memo field into a TStringList object? I am
>stumped...

>FYI, I am using the memo field to store a list of items (similar to an INI
>file) and now I want to read that list of settings back into the program.

>Any help will be appreciated...
>Thanks,
>Dan Cumpian
>Quality Transportation Services

Re:Memo "BLOB" fields and Lists


On Mon, 12 Jul 1999 09:43:08 -0400, "Dan Cumpian" <ir000...@mindspring.com>
wrote:

Quote
>I tried what you suggested and I get "Data type incompatible" error
>messages. What is stored in the memo field is a string list that I created.
>Perhaps what I really have is a long string separated by a CHR(13)?

A string list and a TMemoField are assignment-compatible. But the
FieldByName method returns a reference of type TField, not TMemoField. In
some versions of Delphi this mightr be a problem. Try typecasting the
reference from FieldByName as a TMemoField.

  MyStringList.Assign(TMemoField(myTable.FieldByName('Memo1')));

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski         "Television is a medium because anything well done
Felton, CA             is rare."
                                                 -- Fred Allen (1894-1956)

Re:Memo "BLOB" fields and Lists


After more experimentation, I finally solved it with the following:

  // Retrieve text in memo as string...
  ActionMemo:=FrmAccess.QryAccess['Actions'];

  // Parse string into a Stringlist...
  AppActions.Free;
  AppActions:=TStringList.Create;
  AppActions.Text:=ActionMemo;

Whatever works!!

Thanks for everyone's help.

Dan Cumpian

Quote
Bj?rge S?ther wrote in message ...
>Hi !

>What about

>  MyStringList.text:=MyTable.FieldByName('Memo1').AsString;

>?

>--

>Bjoerge

><<Dan Cumpian skrev i meldingen <7mcref$v1...@nntp5.atl.mindspring.net>...
>Woody,

>I tried what you suggested and I get "Data type incompatible" error
>messages. What is stored in the memo field is a string list that I created.
>Perhaps what I really have is a long string separated by a CHR(13)?

>Any advice?
>Dan

>Woody wrote in message <931558602.206...@news.remarQ.com>...
>>Use the statement

>>    MyStringList.Assign(myTable.FieldByName('Memo1'));

>>Woody

>>Dan Cumpian <ir000...@mindspring.com> wrote in message
>>news:7m5n53$tl1$1@nntp1.atl.mindspring.net...
>>Can anyone tell me how to read a memo field into a TStringList object? I
am
>>stumped...

>>FYI, I am using the memo field to store a list of items (similar to an INI
>>file) and now I want to read that list of settings back into the program.

>>Any help will be appreciated...
>>Thanks,
>>Dan Cumpian
>>Quality Transportation Services

Re:Memo "BLOB" fields and Lists


In article <q4Ei3.68$ur4.2...@news.clear.net.nz>, "Alec Ford"

Quote
<alecf...@clear.net.nz> writes:
>var ca : array [1..12] of ^Tcheckbox; {ca = Component Array}

>procedure TForm1.Button1Click(Sender: TObject);
>begin
>for i := 1 to 12 do begin
>           new(ca[i]);
>           ca[i]^:=Tcheckbox.create(GroupBox1);
>           ca[i]^.caption:='Box #'+inttostr(i);
>           ca[i].parent := GroupBox1;  { assiging a parent is essential}
>           ca[i]^.width:=68;
>           ca[i]^.height:=12;
>           ca[i] ^.top:=4+(i*12);
>           ca[i]^.left:=4;
>           ca[i]^.tag:=i;  {how to know which box in the event handlers}
>           ca[i]^.checked:=true;
>           ca[i]^.onclick:=CheckBox1Click;
>           ca[i]^.onmousedown:=CheckBox1MouseDown;
>           ca[i]^.onmouseup:=CheckBox1MouseUp;
>end;

Alec

If you have an {*word*60}ion to pointers then feel free to use them <gg> but Delphi
references and de-references for you in most cases, and also allocates memory
for the variables and objects.

Note also that you are wasting memory by using New _and_ TCheckBox.Create. They
both make another instance of a TCheckBox. The pointer for the memory for New
is placed in ca[i] and then overwritten by the pointer to memory allocated by
TCheckbox.Create. Therefore the New memory can never be deallocated (you've
lost the pointer to it). New is an old Pascal object statement and should not
now be used. Its also better to use named constants rather than "magic numbers"

Your "clearer, newer" <g> code would appear like :-

var
  ca : array [1..12] of TCheckBox; {ca = Component Array}

var
  i : integer;
const
  CBHeight : integer = 17; // use named constants instead of "magic numbers"
  CBWidth : integer = 70;
begin
  for i := 1 to high(ca) do begin // high(ca) is the last element count easier
to change numbers
    ca[i] := TCheckBox.Create(Self); // Self is the form instance
    with ca[i] do begin
       Parent := GroupBox1;  {assiging a parent is essential} // & should be
first
       Caption := 'Box #' + IntToStr(i);
       SetBounds(4, 4 + (i * CBHeight), CBWidth, CBHeight); // one line instead
of four
       Tag := i;  {to identify which box in the event handlers}
       Checked := true;
       OnClick := CheckBox1Click;
       OnMouseDown := CheckBox1MouseDown;
       OnMouseUp := CheckBox1MouseUp;
    end; {with ca[i]}
  end; {for i := 1 to high(ca)}
  {set group box size in case of change to numbers of check boxes}
  GroupBox1.Height := 4 + (CBHeight * (high(ca) + 1)) + 8;
  GroupBox1.Width := 4 + CBWidth + 8;
end;

You also might find it easier (and conform to general usage) if your arrays had
a lower bound of zero instead of one.

Quote
>For the event handler procedures start with manually creating one component
>and then create the handlers for it, then delete the component from the
>form.

You can just write the procedures yourself and call it any name you like
providing that :-

1 It is a method of the form, ie it has "procedudure TForm1." before the name
of the procedure.

2 It uses the parameters and names appropriate to the event type, for a simple
event  of type TNotifyEvent (like OnClick) it is (Sender : TObject), for a
mouse event of type TMouseEvent it is (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer).

3 The header line ie "procedure MyProcedure(param1 etc" without the TForm1.
prefix, is placed in the list of procedures immediately before the "private"
line in the form's type definition.

Of course doing it your way works (and you could change the name to a more
suitable one by editing the name in the Object Inspector's event page, or by
editing the procedure headers in your code).

Hope this helps

Alan Lloyd
alangll...@aol.com

Other Threads