9

The LA Fox Developer Newsletter
September 1995
Error Trapping (Con't from page 3)


Hot Tip .

Making Browse Key Faster
Using Undocumented Syntax
Requirements
by Wayne Snyder, 71 754,1 553

At one time or another, almost everyone needs to do
a lookup on address. The requirement I had was to
aHowthe userto name a street, streettype like DR, LN,
PKVVY, HWY, etc., street direction like E,W, N, S, as
well as the house number to get to a browse screen.
The user may want the browse to include all streets
whose name begins with “CANNON” and whose street
type is "BLVD", so that all properties for CANNON
BLVD, CANNON TEMPLE BLVD, etc. would popu-
late the browse window.

My solution was to use code like


My assumption is that the street name is the item
which is most likely to be known. When running the
program however, bad response became an issue. If
I entered “CANNON” as the street name with every-
thing else empty, response was fast. If I add I
character to ANY other field, things got slower. Two
characters made it slower still.

In trying to debug the problem I created a small function
which always returned TRUE, but added one to a local
variable. I put this function in the BROWSE FOR clause
so that after the browse was through, I could see how
many records were beEng compared in the FOR clause
of the browse. Sure enough, the more characters
entered in houseno, for instance, the more records were
being compared in the FOR clause, until a full Table
search was being performed. I knew that there were 100
records with a street name of “CANNON”, but all I million
records were being searched. This is not what I ex-
pected at all, but fortunately the solution is very simple.

PUT THE KEY CLAUSE IN FRONT OF THE FOR
CLAUSE, and life will be good again. Imagine that!!!....
I could not find any documentation which suggests the
order of the clauses wou’d make any difference, but it
surely does. The good code looks like


Boy, is this fast!!!! I hope this tip might save you several
days of debugging time! This problem exists in FPW
2.5b and FPW 2.6 and FPW 2.6a.

It Can’t Get Any Easier......
We’ve come up with an easy way to submit articles to
the LA Fox Developer Newsletter one that has
been overlooked for a long time.

You can submit your articles to either Chuck Williams
(72330,2326) or Barry Lee (72723,3422) on
Compuserve.

These articles can be on any FoxPro-related topic,
whether it concerns a new technique you’ve discov-
ered, a certain development technique you may favor
over others, book reviews, etc.

The quality of this newsletter really depends on the
members that support it, not just read it. And I think
we’d all be surprised by the useful information that
could be circulated around the membership.

So.
How bout it?
Page 9

9