dbTalk Databases Forums  

Strange Behaviour in Set Filter Command

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss Strange Behaviour in Set Filter Command in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Graham
 
Posts: n/a

Default Strange Behaviour in Set Filter Command - 05-15-2006 , 09:27 PM






I have two fields title/artist data fields. Want to build a set filter
command from them allowing any and all words entered in a search field
to search the data fields. So I build a filter using or for each word
and 'and' to join the words together. My understanding of VFP is that
the as soon as an expression evaluates as false there is no further
processing of the line. Anyways the following line is embedded in a
loop to cycle through the number of words in the search field.

filter_string=filter_string+'ATC("'+Getwordnum(lse arch,m)+'",title)<>0
or ATC("'+Getwordnum(lsearch,m)+'",artist)<>0 and '

When I exit my loop I strip the last end from the filter and then

Set Filter to &filter_string

What I want it to do is to find all songs that contain all the words in
the artist or title field but instead it returns any record that
matches one word. I have looked at the filter line over and over but I
can't see what's wrong. I guess I can't see the forest for the trees.
Thanks for any help in advance.


Reply With Quote
  #2  
Old   
Josh Assing
 
Posts: n/a

Default Re: Strange Behaviour in Set Filter Command - 05-15-2006 , 10:38 PM






Let me see if I understand
You're building a filter -- based on multiple words
You want to filter your database on having ALL words match not ANY
You're using OR in your filter

If this is all true; I suggest you use AND instead of OR



On 15 May 2006 19:27:07 -0700, "Graham" <grahamskaraoke (AT) gmail (DOT) com> wrote:

Quote:
I have two fields title/artist data fields. Want to build a set filter
command from them allowing any and all words entered in a search field
to search the data fields. So I build a filter using or for each word
and 'and' to join the words together. My understanding of VFP is that
the as soon as an expression evaluates as false there is no further
processing of the line. Anyways the following line is embedded in a
loop to cycle through the number of words in the search field.

filter_string=filter_string+'ATC("'+Getwordnum(lse arch,m)+'",title)<>0
or ATC("'+Getwordnum(lsearch,m)+'",artist)<>0 and '

When I exit my loop I strip the last end from the filter and then

Set Filter to &filter_string

What I want it to do is to find all songs that contain all the words in
the artist or title field but instead it returns any record that
matches one word. I have looked at the filter line over and over but I
can't see what's wrong. I guess I can't see the forest for the trees.
Thanks for any help in advance.

--- AntiSpam/harvest ---
Remove X's to send email to me.


Reply With Quote
  #3  
Old   
PM Godfrey
 
Posts: n/a

Default Re: Strange Behaviour in Set Filter Command - 05-16-2006 , 08:00 AM



Try:

filter_string=filter_string ;
+ '(ATC("'+Getwordnum(lsearch,m)+'",title)<>0 or
ATC("'+Getwordnum(lsearch,m) +'",artist)<>0 ) and '

Note the ATC() OR ATC() is placed in parentheses.

Remember logical 'operator precedence' is:
()
NOT
AND
OR


This may or may apply:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_3qpf.asp>



On 15 May 2006 19:27:07 -0700, "Graham" <grahamskaraoke (AT) gmail (DOT) com>
wrote:

Quote:
I have two fields title/artist data fields. Want to build a set filter
command from them allowing any and all words entered in a search field
to search the data fields. So I build a filter using or for each word
and 'and' to join the words together. My understanding of VFP is that
the as soon as an expression evaluates as false there is no further
processing of the line. Anyways the following line is embedded in a
loop to cycle through the number of words in the search field.

filter_string=filter_string+'ATC("'+Getwordnum(lse arch,m)+'",title)<>0
or ATC("'+Getwordnum(lsearch,m)+'",artist)<>0 and '

When I exit my loop I strip the last end from the filter and then

Set Filter to &filter_string

What I want it to do is to find all songs that contain all the words in
the artist or title field but instead it returns any record that
matches one word. I have looked at the filter line over and over but I
can't see what's wrong. I guess I can't see the forest for the trees.
Thanks for any help in advance.


Reply With Quote
  #4  
Old   
Graham
 
Posts: n/a

Default Re: Strange Behaviour in Set Filter Command - 05-16-2006 , 09:28 AM



Josh unable to use only AND as I wish to search two fields for an
occurrence of the search word.

PM Godfrey. Thank you. I was forgetting about precedence order. That
did the trick.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.