Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Have I made any errors in this code?
Message
 
À
29/08/2012 12:12:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01551822
Message ID:
01551839
Vues:
56
>>>>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 &&& TEMP DEBUG
>>>>			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;
- what if a particular tempkey is also a fragment of unrelated word in lcText
.....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform