DBMemo reluctant to give away lines...!? 
Author Message
 DBMemo reluctant to give away lines...!?

Here's my problem. I'm trying to make a search routine that will check the
contents of several entry boxes for the occurrence of certain search keywords.
One of my entry boxes is a DBMemo control, which at first seemed to me fairly
innocent. Part of my search screen includes a case-sensitivity option. If case
sensitivity is turned OFF, then I want to make a copy of the DBMemo's contents
in another place (TStrings object in this case), and "UpperCase" the copy.
Doing this, the search routine finds words when it should, however it does
some strange things with the original DBMemo's text. Basically, UpperCase'ing
the copy of the DBMemo seems to actually change the *real*, original DBMemo:
After doing a search, the DBMemo contains ALL CAPS! Below is a snippet of code
from the search routine. I *must* be doing something horribly wrong, but I
can't figure it out. The UpperCase command is never used on the DBMemo, so
I'm really baffled. Any help or suggestions for a different approach would be
much appreciated.

Thanks,

Kris Wilk
ReefNet Software

CODE BEGINS HERE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure SearchDive(DoAnd : boolean);
var
   tempdate, templocation, tempbuddy : string;
   tempdesc : TStrings;
   i : longint;
begin
     with MainForm do
     begin
       tempdate := DiveLogTable.FieldByName('Date').AsString;
       templocation := DiveLogTable.FieldByName('Location').AsString;
       tempbuddy := DiveLogTable.FieldByName('Buddy').AsString;

       tempdesc := DbMemo1.Lines;  {Copy original memo to temp storage}
     end;

     if not SearchDialog.DLSearchCaseSensitive.Checked then
       begin
            tempdate := UpperCase(tempdate);
            templocation := UpperCase(templocation);
            tempbuddy := UpperCase(tempbuddy);
            for i := 0 to tempdesc.count - 1 do
               tempdesc[i] := UpperCase(tempdesc[i]); {<--MAKES DBMemo1 CAPS!}
       end;
.
.
.
 and so on........
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CODE ENDS HERE



Thu, 15 Jul 1999 03:00:00 GMT  
 DBMemo reluctant to give away lines...!?

First off, tempdesc is just a pointer to a TStrings object. Try the
following:

tempdesc := TStrings.Create(nil);
try
   tempdesc.Assign(DbMemo1.Lines);
   ..
   .. work with tempdesc
   ..
finally
   // We need to free the TStrings Object that we've created
   tempdesc.Free;
end;

 procedure SearchDive(DoAnd : boolean);
 var
    tempdate, templocation, tempbuddy : string;
    tempdesc : TStrings;
    i : longint;
 begin
      with MainForm do
      begin
        tempdate := DiveLogTable.FieldByName('Date').AsString;
        templocation := DiveLogTable.FieldByName('Location').AsString;
        tempbuddy := DiveLogTable.FieldByName('Buddy').AsString;
        tempdesc := TStrings.Create(nil);       // Added
      end;
       try              // Added
         tempdesc.Assign(MainForm.DbMemo1.Lines);  {Copy original memo to
temp storage}   // Changed
         if not SearchDialog.DLSearchCaseSensitive.Checked then
         begin
             tempdate := UpperCase(tempdate);
             templocation := UpperCase(templocation);
             tempbuddy := UpperCase(tempbuddy);
             for i := 0 to tempdesc.count - 1 do
                tempdesc[i] := UpperCase(tempdesc[i]); {<--MAKES DBMemo1
CAPS!}
         end;
      finally           // Added
          tempdesc.Free;        // Added
      end;              // Added
 .
 .
 .
  and so on........
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 CODE ENDS HERE


Quote:
> Here's my problem. I'm trying to make a search routine that will check
the
> contents of several entry boxes for the occurrence of certain search
keywords.
> One of my entry boxes is a DBMemo control, which at first seemed to me
fairly
> innocent. Part of my search screen includes a case-sensitivity option. If
case
> sensitivity is turned OFF, then I want to make a copy of the DBMemo's
contents
> in another place (TStrings object in this case), and "UpperCase" the
copy.
> Doing this, the search routine finds words when it should, however it
does
> some strange things with the original DBMemo's text. Basically,
UpperCase'ing
> the copy of the DBMemo seems to actually change the *real*, original
DBMemo:
> After doing a search, the DBMemo contains ALL CAPS! Below is a snippet of
code
> from the search routine. I *must* be doing something horribly wrong, but
I
> can't figure it out. The UpperCase command is never used on the DBMemo,
so
> I'm really baffled. Any help or suggestions for a different approach
would be
> much appreciated.

> Thanks,

> Kris Wilk
> ReefNet Software

> CODE BEGINS HERE
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> procedure SearchDive(DoAnd : boolean);
> var
>    tempdate, templocation, tempbuddy : string;
>    tempdesc : TStrings;
>    i : longint;
> begin
>      with MainForm do
>      begin
>        tempdate := DiveLogTable.FieldByName('Date').AsString;
>        templocation := DiveLogTable.FieldByName('Location').AsString;
>        tempbuddy := DiveLogTable.FieldByName('Buddy').AsString;

>        tempdesc := DbMemo1.Lines;  {Copy original memo to temp storage}
>      end;

>      if not SearchDialog.DLSearchCaseSensitive.Checked then
>        begin
>             tempdate := UpperCase(tempdate);
>             templocation := UpperCase(templocation);
>             tempbuddy := UpperCase(tempbuddy);
>             for i := 0 to tempdesc.count - 1 do
>                tempdesc[i] := UpperCase(tempdesc[i]); {<--MAKES DBMemo1
CAPS!}
>        end;
> .
> .
> .
>  and so on........
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> CODE ENDS HERE



Thu, 15 Jul 1999 03:00:00 GMT  
 DBMemo reluctant to give away lines...!?

Quote:

>Here's my problem. I'm trying to make a search routine that will check the
>contents of several entry boxes for the occurrence of certain search keywords.
>One of my entry boxes is a DBMemo control, which at first seemed to me fairly
>innocent. Part of my search screen includes a case-sensitivity option. If case
>sensitivity is turned OFF, then I want to make a copy of the DBMemo's contents
>in another place (TStrings object in this case), and "UpperCase" the copy.
>Doing this, the search routine finds words when it should, however it does
>some strange things with the original DBMemo's text. Basically, UpperCase'ing
>the copy of the DBMemo seems to actually change the *real*, original DBMemo:
>After doing a search, the DBMemo contains ALL CAPS! Below is a snippet of code
>from the search routine. I *must* be doing something horribly wrong, but I
>can't figure it out. The UpperCase command is never used on the DBMemo, so
>I'm really baffled. Any help or suggestions for a different approach would be
>much appreciated.
>Thanks,
>Kris Wilk
>ReefNet Software
>CODE BEGINS HERE
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>procedure SearchDive(DoAnd : boolean);
>var
>   tempdate, templocation, tempbuddy : string;
>   tempdesc : TStrings;
>   i : longint;
>begin
>     with MainForm do
>     begin
>       tempdate := DiveLogTable.FieldByName('Date').AsString;
>       templocation := DiveLogTable.FieldByName('Location').AsString;
>       tempbuddy := DiveLogTable.FieldByName('Buddy').AsString;
>       tempdesc := DbMemo1.Lines;  {Copy original memo to temp storage}
>     end;
>     if not SearchDialog.DLSearchCaseSensitive.Checked then
>       begin
>            tempdate := UpperCase(tempdate);
>            templocation := UpperCase(templocation);
>            tempbuddy := UpperCase(tempbuddy);
>            for i := 0 to tempdesc.count - 1 do
>               tempdesc[i] := UpperCase(tempdesc[i]); {<--MAKES DBMemo1 CAPS!}
>       end;
>.
>.
>.
> and so on........
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>CODE ENDS HERE

I was just curious, have you had success stepping through paradox
records in search of text in a DBMemo field?

I am having problems with this, and was hoping you or someone
knolodglable on this topic could answer this..

Here is the two functions am using to search ..

{--------------------------------------------------------------------------}
function TMainForm.FindText(aString : String) : Boolean;
var
 I : Integer;
begin
 Result := False;

    for I := 0 to DiaryDBMemo.Lines.Count -1 do
        if Pos(aString, DiaryDBMemo.Lines.Strings[I]) > 0 then
         begin(* String found *)
          MessageDlg('Found ' + aString, mtInformation,[mbOk], 0);
          Result := True;
          Exit;
         end
        else
         Result := False;
         MessageDlg('Cound''nt Find ' + TextToFind,
                                    mtInformation,[mbOk], 0);
         Exit;
end;

{--------------------------------------------------------------------------}
procedure TMainForm.SearchDiaryBtnClick(Sender: TObject);
var
 Found : Boolean;
begin
 Found := False;
 TextToFind := SearchStringEdit.Text;
 AbortSearch := False;
 if TextToFind <= '' then Exit;
  try
   with DiaryTable do
   begin
    First;    
    while not EOF  do
     Found := FindText(TextToFind);
     if Found then
      begin
      Exit;
      end
     else      
      Next;
     end;
  finally
 {}
   end;
end;

The result is a system hang...

Any suggestions would be appreciated..

RKr



Thu, 15 Jul 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. 2 seconds away from giving up! :(

2. Will give away code for VESA 24/32-bit Putpixel routine

3. Line procedure (with coordinates given)

4. Problems with Adding lines to DbMemo in MsAccess db - BDE keeps shouting errors after several records

5. BP7 Dll Export; line gives Begin Expected Error

6. Read file line per line

7. Newbie question about moving thru table line by line

8. Can I turn 26 line mode to 50 line mode

9. Blank line between lines: HELP!

10. Trouble printing a BST line by line

11. pascal lang. is fading away

12. 'Fly-away' records and SQL

 

 
Powered by phpBB® Forum Software