` Printed Icetips Article

Icetips Article



ABC: Using filtered locators
1998-12-31 -- Dennis E. Evans
 
Newsgroups: topspeed.products.c5pe

>All the replys where helpfull but not what I was looking for. What I would
>like to do is take a value entered by the user and scroll to the next record
>that contains the texted. Clarion has some pretty nice query fuctions and
>even the incremental search is nice but sometimes you don't know the exact
>spelling and doing a query on a large file takes forever. Access has this
>feature built-in and I would think Clarion(Topspeed) could do the same.

    I had a similar request in an application a while back,
the user even mentioned Access.  I really did not want to try
and explain the different ways a page loaded browse worked and how Access
works.

Not sure this is what you are looking for, I debated about
posting  but it may give you a couple of ideas.

As with all problems in this business there is probably a half a dozen other
ways to solve it, but this one does work
and is fairly simple.

I did this originally in CW4b and all seems to be well
since I upgraded.

Performance is not what you would call blinding fast but is acceptable, it
has to be as fast as a sequential search.

This has been used on a file with just over 30,000 records not huge but fair
sized.

And finally the solution :

Open the embed editor and add local variable to be used
for the user input and a class instance of the
FilterLocatorClass to be used to set the filter stuff.

WorkStr           string(20)     ! or whatever you need
FindItLocator   FilterLocatorClass

in the Window.Init method, after the browse is initialized,
initialize the locator:

FindItLocator.Init(,Fil:KeyFielName,1,BRWx)
FindItLocator.FloatRight = true

Note there is no control passed in the init method call.  The browse does
not know about the locator but the locator knows about the browse.
The Float right property is what allows the filter expression to use
the instring condition.

In the Window.Kill method add this
FindItLocator.Destruct()     ! nulls the FreeElement field, which
is an ANY type.

Add an entry control to the tab needed
In the control event handling 'Accepted'
add this :

if WorkStr = ''
     FindItLocator.Set()                ! clear the locator
     FindItLocator.UpdateWindow()  ! clear the filter condition
     Brwx.UpdateBuffer()      ! make sure the buffer is loaded
     Brwx.ResetFromBuffer() ! reset from the buffer
  else
     FindItLocator.Shadow = clip(WorkStr)  ! set the shadow
     FindItLocator.UpdateWindow()        ! add to filter
     Brwx.ResetQueue(Reset:Queue)     ! redisplay the browse
  end ! if

Now what happens is when the user enters something like
'on' and presses the tab key.  All fields with 'on' will be displayed.
Jones, Johnson, On Sale, etc...
They can then add to the condition or work with what
they have.   When they are done all the user needs to
do is blank the workstr variable and the browse is
redisplayed and the current record will be highlighted.

Again not sure this is what you are looking for but may get you started.

Hope it helps.

        Dennis



Printed November 21, 2024, 7:07 am
This article has been viewed/printed 35364 times.
Google search has resulted in 29 hits on this article since January 25, 2004.