No subject
Steve Kane
skane-l at skaneco.com
Tue Mar 4 21:10:12 PST 2008
I wrote a procedure triggered by the closing of a TESO that allows me
to type several words into a TESO that will find the records which
contain all of the words in several fields. I've got it to work but I
think it is clumsy and I strongly suspect a real programmer would do
it differently. I suspect there are tools in Pan 5.5 to do this more
cleanly. To put it another way, my procedure is so Pan 1.5. I'd
appreciate any ideas as to alternate ways of doing this that might be
more programmer-like and maybe more portable. Alternatively, I'd like
any ideas as to how to achieve line number 7, which would add
parentheses which I think would make the procedure more reliable.
Thanks.
As an example, let's say the user types " apple mac photo "
including spurious spaces into the TESO. I would like to select all
the records which contain all of these words even if the words are in
different fields, namely URL, Title and Notes.
This is my procedure:
vSelectText = arraystrip(vSelectText," ")
arrayfilter vSelectText,vSelectText," ",chr(34)+import()+chr(34)
vSelectText = replace(vSelectText," "," AND URL + Title + Notes
CONTAINS " )
vSelectText = "URL + Title + Notes CONTAINS " + vSelectText
vSelectText = "Select " + vSelectText
execute vSelectText
Here's what happens:
1) user types: " apple mac photo " without the quotes
2) this procedure code cleans up the input, removing stray spaces:
vSelectText = arraystrip(vSelectText," ")
outputs this result:
apple mac photo
3) this procedure code:
arrayfilter vSelectText,vSelectText," ",chr(34)+import()+chr(34)
outputs this result:
"apple" "mac" "photo"
4) this procedure code:
vSelectText = replace(vSelectText," "," AND URL + Title + Notes
CONTAINS " )
outputs this result:
"apple" AND URL + Title + Notes CONTAINS "mac" AND URL + Title +
Notes CONTAINS "photo"
5)this procedure code:
vSelectText = "URL + Title + Notes CONTAINS " + vSelectText
outputs this result:
URL + Title + Notes CONTAINS "apple" AND URL + Title + Notes CONTAINS
"mac" AND URL + Title + Notes CONTAINS "photo"
6) this procedure code:
vSelectText = "Select " + vSelectText
outputs this result:
Select URL + Title + Notes CONTAINS "apple" AND URL + Title + Notes
CONTAINS "mac" AND URL + Title + Notes CONTAINS "photo"
7) can't figure out how to achieve this output:
(URL + Title + Notes CONTAINS apple) AND (URL + Title + Notes
CONTAINS mac) AND (URL + Title + Notes CONTAINS photo)
8) this line executes the select:
execute vSelectText
More information about the Qna
mailing list