>>>>>>I suspect I have made a mistake and cannot see it. Can you?
>>>>>>I am looking up a key word and seaching a string (lcTEXT) for that key word.
>>>>>>If the keyword is found then 30 characters on either side of the found key word
>>>>>>should be collected and stored in the results table.
>>>>>>
>>>>>>VFP Help is pasted below.
>>>>>>
>>>>>>
>>>>>>***********************WORKING HERE*************************
>>>>>> IF LEN(ALLTRIM(lcTEXT)) > 3
>>>>>> SELECT KEYWORDS
>>>>>> SCAN
>>>>>> TempKey = KEYWORDS.keyword
>>>>>> TempKey = LOWER(TempKey)
>>>>>> TempCtrlWord = KEYWORDS.ctrlword
>>>>>> IF Tempkey $ lcTEXT
>>>>>> SELECT results
>>>>>> APPEND BLANK
>>>>>> REPLACE results.WORD WITH TempKey
>>>>>> REPLACE results.ctrlword WITH TempCtrlWord
>>>>>> WordStart = AT(lcTEXT, TempKey,1)
>>>>>> PreWord = SUBSTR(lcTEXT,(WordStart-31),30)
>>>>>> REPLACE Results.pre WITH PreWord
>>>>>> WordEnd = RAT(TempKey,lcTEXT,1)
>>>>>> PostWord = SUBSTR(lcTEXT,(WordEnd+1),30)
>>>>>> REPLACE Results.Post WITH PostWord
>>>>>> SELECT KEYWORDS
>>>>>> Thisform.refresh
>>>>>> ENDIF
>>>>>> ENDSCAN
>>>>>>********************END WORKING HERE*************************
>>>>>>
>>>>>>
>>>>>
>>>>>Whether there are errors, then probably debug will show them. But I would say, there are many uncertaincies:
>>>>>- why LEN(ALLTRIM(lcTEXT)) > 3; whether,it is good enough if you are looking for 30 characthers befor and 30 characters after the tempkey that also has a length?
>>>>>- wheter lcText always in lower case?
>>>>>- whether KEYWORDS.keyword does not cointain spaces at the right or left? Whether tempkey always has length of KEYWORDS.keyword ?
>>>>>.......
>>>>>
>>>>>Good Luck
>>>>> 3 = is checking to make sure lcTEXT is not ""
>>>>lcTEXT is lowercase - I ised LOWER(lcTEXT) on it
>>>>I will add alltrim() to the routine and repott back. - Thanks :-)
>>>
>>>
>>>FIXED!! It was alltrim() - Thank you .
>>
>>
>>I glad you fixed it. But I still doubt that the code is healthy (just because I do not know anything in paricular about lcTExt and
>>KEYWORDS.keyword values):
>>
>>- what if there are several tempkeys in lctext? Then AT and RAT will give you different anbd not synchronized positions in lcText; (I'll use the 'occurance' option)
>>- what if a particular tempkey is also a fragment of unrelated word in lcText -(Handled by adding a space on either end of the word. Eliminates junk from the headers)
>>..... Thanks again
>
>For me, this is a fun and recreational project. (Keeps my old brain thinking:-)
Ah! If that's the case, then you would get far better performance by doing a single write to the table and indexes.
IF LEN(ALLTRIM(lcTEXT)) > 3
SELECT KEYWORDS
SCAN
TempKey = LOWER(KEYWORDS.keyword)
TempCtrlWord = KEYWORDS.ctrlword
IF Tempkey $ lcTEXT
WordStart = AT(lcTEXT, TempKey,1)
PreWord = SUBSTR(lcTEXT,(WordStart-31),30)
WordEnd = RAT(TempKey,lcTEXT,1)
PostWord = SUBSTR(lcTEXT,(WordEnd+1),30)
INSERT INTO RESULTS ;
(WORD, ctrlword, pre, Post) ;
VALUES ;
(TempKey, TempCtrlWord,PreWord,PostWord)
Thisform.refresh
ENDIF
ENDSCAN