Subject Re: SEEKER
From CORNELIUS <jcmsoftware@gmail.com>
Date Fri, 04 Jan 2019 00:02:10 -0500
Newsgroups dbase.getting-started

Akshat Kapoor Wrote:

> On 02/01/2019 14:34, Mervyn Bick wrote:
> > On 2019-01-02 10:23 AM, CORNELIUS wrote:
> >> Hi threre,
> >>
> >> I have updated to dbase 12.
> >>
> >> I have a stock file with a stock description.
> >> I know that seeker will shift the active line in a file as you type in
> >> the description.
> >> I want to be able to type in a part of the description and then the
> >> program to list all stock with that part of description.
> >> For example if I type in "SILVER" all descriptions with the word
> >> "SILVER" in it must be displayed.
> >>
> >> Hope someone has done this and thanks,Cornelius
> >>
> >
> > The seeker control only finds the first record where the contents of the
> > searched field starts with the characters typed into the seeker.  The
> > more characters entered, the closer the rowpointer gets to the required
> > record.
> >
> > To do what you want you will need to use  LIKE  in the WHERE clause of a
> > parameter driven query's SQL statement.  Be aware though that this is
> > not really efficient code.  On very large tables there may be delays in
> > fetching the required records.
> >
> > LIKE uses % as a wild card for any number of characters.  Setting the
> > parameter to %SILVER%  will find  all records where the characters
> > SILVER appear anywhere in the field being searched.  SILVER% will find
> > records where the contents of the field starts with SILVER.  This will
> > be faster than $SILVER% as the SQL engine can make use of an index to
> > help speed up the search.
> >
> > In the attached example I've used lower() to make the search
> > case-insensitive.
>
> This is only required if number of rows is greater than 10K or data is
> to be sent over network and is causing slow response due to frequent
> requery()
>
> I use a very similar form with the following additions
> In form_onOpen event
>
> form.twait = false
> form.timer = new timer()
> form.timer.parent = form
> form.timer.interval = 0.75
> form.timer.ontimer = {;form.twait = false ; form.timer.enabled = false;
> form.searchcode_onkey2()}
> (beware of word wrap in above line)
>
>
> Replace searchcode with entryfield1
>
> function SEARCHCODE_onKey(nChar, nPosition,bShift,bControl)
>         if form.twait
> //                //do nothing
> //                //We are waiting for additional key strokes
>         else
>                 form.twait = true
>                 form.timer.enabled = true                
>         endif
>        return
>
>
> function SEARCHCODE_onKey2(nChar, nPosition,bShift,bControl)
>         if sc <> alltrim(upper(form.searchcode.value))
>            sc = alltrim(upper(form.searchcode.value))
>             form.invedatamodule1.inve.params["SC"] = "%"+sc+"%"
>             form.invedatamodule1.inve.requery()
>            form.rowset.first()
>         endif
>         form.mun_grid1.refresh()
>        return
>
> I have a habit of using upper() to make search case insensitive.
>
>
> Using this code I wait for 0.75 seconds for additional key strokes
> before requery().
> This may speed up the process.
>
> Regards
> Akshat


Thank you Mervyn and Akshat for the info. GOD BLESS and I will work on it today. Seems it will also work with 6.21. Nice day. Cornelius