Re: Best approach?

Tech-Archive recommends: Speed Up your PC by fixing your registry



DIMENSION cArray (4,1)
cArray(1,1)='RED'
cArray(2,1)='PAINT'
cArray(3,1)='SPRAY'
cArray(4,1)='CAN'
CREATE CURSOR searchwords (word char(20))
INSERT INTO Searchwords FROM ARRAY cArray
CREATE CURSOR inventory (id Int, descript Memo)
INSERT INTO Inventory VALUES (1,'SPRAY HAIR BLUE')
INSERT INTO Inventory VALUES (2,'PAINT RED SPRAY')
INSERT INTO Inventory VALUES (3,'BLUE HAIR SHAMPOO')

SELECT COUNT(*),id,word, MAX(CAST(descript as char(40)))as descript ;
FROM inventory,Searchwords WHERE descript like '%'+TRIM(word)+'%' ;
GROUP BY id,word ;
INTO CURSOR Q1

SELECT SUM(cnt),id,descript FROM Q1 GROUP BY 2,3 INTO CURSOR Q3
BROWSE
Q3 shows that there were 1 hit in record #1, and 3 hits in record #2, for
the 4 searchwords.

-Anders


"John Germany" <jgphotography@xxxxxxxxxxxxxx> wrote in message
news:um9r0y6hIHA.2540@xxxxxxxxxxxxxxxxxxxxxxx
I've written a function that parses a search string and returns a 1D array
for each word in the string.
Such as, "PAINT SPRAY RED" would return an array of
cArray[1,1]="PAINT"
cArray[2,1]="SPRAY"
etc.
Now I want to issue a SELECT statement to search my inventory file
Select * from inventory WHERE cArray[1,1]$descript AND .... (or several
other fields may be searched) and so on...

The problem is that I can't hard code the select statement because the
function will create the number of elements for the array based on how
many search terms are entered. I'm assuming a user defined function in
the select to return the WHERE clause would work, but is this best? (or is
this even permissable and will a UDF in a Select statement return correct
results?)
What would be the best approach for this?
How do search engines like google parse the search string and then return
the results to a cursor?
Thanks,
John
I'm using VFP8SP1

id



.



Relevant Pages

  • Re: Best approach?
    ... INSERT INTO Searchwords FROM ARRAY cArray ... CREATE CURSOR inventory (id Int, descript Memo) ... INSERT INTO Inventory VALUES ...
    (microsoft.public.fox.programmer.exchange)
  • Re: array to iterator
    ... protected Objectarray; ... protected int length; ... * This member is used to keep track of the cursor of the iterator. ...
    (comp.lang.java.programmer)
  • Re: How about this?
    ... When parsing your values into a multirow array (or cursor) you can also ... Then, when displaying the grid, you can change the backcolor of every ...
    (microsoft.public.fox.programmer.exchange)
  • Re: How do I write an array to a text file?
    ... CREATE CURSOR temp ... You now have the array, the table, and the textfile. ... record keys, and a few buttons to Save, Print, Fix, and Exit. ...
    (microsoft.public.fox.helpwanted)
  • Re: Array Question.
    ... >placing txt boxes with a reference to the array e.g. arraythen ... >arrayand so on 25 lines of 12 on the report. ... >i thought using an array to create what i neede was the simplest. ... >i need to do is use a cursor like mentioned below and go with that. ...
    (microsoft.public.fox.programmer.exchange)