Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Building a WHERE clause
Message
From
12/12/1998 15:07:15
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00166558
Message ID:
00166910
Views:
14
>lcWhere = ''
>FOR i=1 TO ALEN(laFilter)
> IF i = 1
> lcWhere = ALLT(laFilter[i])
> ELSE
> IF ! EMPTY(laFilter[i])
> lcWhere = lcWhere + ' AND ' + ALLT(laFilter[i])
> ENDIF
> ENDIF
>NEXT i
>
>Wouldn't something like that work? Obviously you could get more elaborate.
>
>Wayne

My preferred way of dealing with things like this:

lcWhere = ''
lcAnd=""
FOR i=1 TO ALEN(laFilter)
IF ! EMPTY(laFilter[i])
lcWhere = lcWhere + lcAnd + ALLT(laFilter[i])
lcAnd=" and "
ENDIF
NEXT i

Not doing much, just for shorter code and one less nested IF.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform