Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comparison != What have I missed?
Message
De
14/12/2012 13:04:07
 
 
À
14/12/2012 12:20:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Divers
Thread ID:
01559575
Message ID:
01559682
Vues:
58
Once again let me state that this is recreational programming - There is no deadline or money involved.

I am scanning for up to five indicators. When I apply the suggested method, indicator 1 and indicator 5 are the same and 2-3 and 4 are the same. If I put parentheses around each comparison (below) the outcome is 1-2 and 5 are all different and 4 is a duplicate of 3.

Here's the 3-4 code. Next. I'll try with the '!' inside the braces? (Tried it and it's still the same outcome)
		SCAN
			m.TheWord3 = ALLTRIM(LOWER(indicator)) && Symptom
			IF m.TheWord3 $ lcTEXT AND ! (m.TheWord1 == m.TheWord3) OR !(m.TheWord2 == m.TheWord3)
				REPLACE hits WITH indicator.hits + 1 && Gather simple stats
				m.sidenote3 = action && Recommendation
				SELECT MASTER
				REPLACE indicator3 WITH m.sidenote3
			ENDIF
			SELECT indicators
		ENDSCAN
		SCAN
			m.TheWord4 = ALLTRIM(LOWER(indicator)) && Symptom
			IF m.TheWord4 $ lcTEXT AND ! (m.TheWord1 == m.TheWord4) OR !(m.TheWord2 == m.TheWord4) OR !(m.TheWord3 == m.TheWord4)
				REPLACE hits WITH indicator.hits + 1 && Gather simple stats
				m.sidenote4 = action && Recommendation
				SELECT MASTER
				REPLACE indicator4 WITH m.sidenote4
			ENDIF
			SELECT indicators
		ENDSCAN
>AND will be processed before OR, so in the first SCAN, it will do
>
>m.TheWord3 $ lcTEXT AND ! m.TheWord3 == m.TheWord1
>
>If that passes, VFP will process OR ! m.TheWord3 == m.TheWord2
>
>The solution is to use parens
>
>m.TheWord3 $ lcTEXT AND (! m.TheWord3 == m.TheWord1 OR ! m.TheWord3 == m.TheWord2)
>
>This will force the OR to be processed before the AND.
>
>>It's almost working, but 4 always equals 3 and I cannot see why.
>>Here's the latest code (attempt):
>>
>>		SCAN
>>			m.TheWord3 = ALLTRIM(LOWER(indicator)) && Symptom
>>			IF m.TheWord3 $ lcTEXT AND ! m.TheWord3 == m.TheWord1 OR ! m.TheWord3 == m.TheWord2
>>				REPLACE hits WITH indicator.hits + 1 && Gather simple stats
>>				m.sidenote3 = action && Recommendation
>>				SELECT MASTER
>>				REPLACE indicator3 WITH m.sidenote3
>>			ENDIF
>>			SELECT indicators
>>		ENDSCAN
>>		SCAN
>>			m.TheWord4 = ALLTRIM(LOWER(indicator)) && Symptom
>>			IF m.TheWord4 $ lcTEXT AND ! m.TheWord4 == m.TheWord1 OR ! m.TheWord4 == m.TheWord2 OR ! m.TheWord4 == m.TheWord3
>>				REPLACE hits WITH indicator.hits + 1 && Gather simple stats
>>				m.sidenote4 = action && Recommendation
>>				SELECT MASTER
>>				REPLACE indicator4 WITH m.sidenote4
>>			ENDIF
>>			SELECT indicators
>>		ENDSCAN
>>
>>
>>
>>
>>>Are you sure m.TheWord2 is in lcText? If the first condition fails, VFP won't do the second. Perhaps you want an OR instead of AND?
>>>
>>>If the IF logic is correct, create a small dataset with two records, one that you know will pass and one that won't. Step through the code with the debugger. Check values of the variables before going into the IF statement. Also, check the value of SET("EXACT") at that same point.
>>>
>>>
>>>>Thanks Craig and all who are helping. I've been using SET EXACT all along, but this little nipper is a PITA that has all indications of being one of those insignificant "I could have had a V8' moments. (something simple, but overlooked) I noticed that I misspelled 'sidenote' as 'sidenotes' also, but have replaced that portion below. Still no luck with this problem, but it's keeping my elderly brain working. :-)
I ain't skeert of nuttin eh?
Yikes! What was that?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform