Board index » cppbuilder » Form1->Table1->Locate() acting different now!

Form1->Table1->Locate() acting different now!

Hello there!

Anyone experienced Locate() acting one way once, and completelly different
after n-th rebuild?
The code below used to reposition cursor as Locate() was approaching the
record I was looking for, for every key I have pressed (if there was a
match). The Edit used to enter the Locate() criteria has blue text if
approaching/match or red text for failure.
Now, it repositions the cursor only if I type the entire value of the field
I am trying to locate.
Why is loPartialKey not working anymore?

I have rebuilt the app several times (every changes I make, I rebuild the
app to see it working), when I saw the difference, but anthing I do to clean
the project directory (I have erased all files except *.cpp, *.h, *.dfm and
*.bpr), no result. Several times, the app forgets the icon I set for the
exe, and shows the Delphi standard icon (not even Builder's).
I do manage versions copying the entire directory (BCB is not in use at this
time), rename old directory, and then double click the *.bpr in the new
folder. I had some surprises to work (in vain) in the previos version's
files and see both the old and the new version not working at all :-). But
this is another history.

//--------------------------------------------------------------------------
-
int searchRecord(TEdit *Ce)
{
    AnsiString Mm;
    TLocateOptions Opts;
    Opts.Clear();
    Opts << loPartialKey;  // this should make Locate() able to find records
based partial values of that record, isn't it?
    Opts << loCaseInsensitive;
    Variant locvalues[2];
    locvalues[0] = Variant(Mm);
    locvalues[1] = Variant("P");
    AnsiString Nn;
    int YES = 0;

  Mm.cat_sprintf("%s", Ce->Text);
  if(Ce->Name == "Edit1")
  { Mm.SetLength(5);
    YES = Form1->Table1->Locate("Code", Mm, Opts);
  }

  if(YES) Ce->Font->Color = clBlue;
  else   Ce->Font->Color = clRed;
  return 0; //return = 0 for now, because it might need to return something
later

Quote
}

//--------------------------------------------------------------------------
-

Here I call the search function:
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
searchRecord(Edit1);  //

Quote
}

//--------------------------------------------------------------------------
-

By the way: OnKeyDown()  calls OnChange().
How can I skip OnChange() for certain keys pressed? (like VK_UP, VK_DOWN,
VK_NEXT, VK_PRIOR).

Regards
Adrian

 

Re:Form1->Table1->Locate() acting different now!


Mm was placed in the wrong place. Damn, I was looking for it for days! Real
stupid.

// -------------------------------------------------------------------------
-

Quote
> -
> int searchRecord(TEdit *Ce)
> {
>     AnsiString Mm;
>     Mm.cat_sprintf("%s", Ce->Text);  // --[new init-the original one]---
>     TLocateOptions Opts;
>     Opts.Clear();
>     Opts << loPartialKey;  // this should make Locate() able to find
records
>                                        //  based partial values of that
record, isn't it?
>     Opts << loCaseInsensitive;
>     Variant locvalues[2];
>     locvalues[0] = Variant(Mm);
>     locvalues[1] = Variant("P");
>     AnsiString Nn;
>     int YES = 0;

>   // --[old init.]---Mm.cat_sprintf("%s", Ce->Text);
>   if(Ce->Name == "Edit1")
>   { Mm.SetLength(5);
>     YES = Form1->Table1->Locate("Code", Mm, Opts);
>   }

>   if(YES) Ce->Font->Color = clBlue;
>   else   Ce->Font->Color = clRed;
>   return 0; file://return = 0 for now, because it might need to return
something
> later
> }

file://---------------------------------------------------------------------
-----
Quote
> -

> Here I call the search function:

file://---------------------------------------------------------------------
-----
Quote
> -
> void __fastcall TForm1::Edit1Change(TObject *Sender)
> {
> searchRecord(Edit1);  //
> }

file://---------------------------------------------------------------------
-----

- Show quoted text -

Quote
> -

Other Threads