Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Always stops evaluating if..?
Message
De
16/08/2005 07:06:05
 
 
À
16/08/2005 06:22:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Divers
Thread ID:
01041159
Message ID:
01041267
Vues:
23
>>>>>As far as I know, vfp always stops evaluating the right remainder of a logical expression if the left part evaluates to an logical value that cannot be changed anymore by the right remainder. For example, in the case of IF A OR B, the B is no longer evaluated if A evaluates to True. In a same vein, in the case of IF A=0 or BB(), the function BB is not visited if A=0.
>>>>>
>>>>>But now I am confronted with a case in a select-sql WHERE expression, where the part to the right of the OR is visited anyhow, notwithstanding the result of the left expression.
WHERE ( MOD(A,1000)#0 OR THERMO(A) )
>>>>>
>>>>>Does this sound familiar to anyone here?
>>>>
>>>>You ignores the phase of analysis,
>>>>and
>>>>Check A, it should to be NULL.
>>>
>>>It is never NULL.
>>
>>Post more info.
>>Look this:
>>
>>clear
>>SET NULLDISPLAY TO "I'm null"
>>CREATE CURSOR myTest (A I NULL)
>>INSERT INTO myTest VALUES (5)
>>INSERT INTO myTest VALUES (0)
>>INSERT INTO myTest VALUES (0)
>>INSERT INTO myTest VALUES (null)
>>INSERT INTO myTest VALUES (2)	&& VFP don't visit THERMO here
>>INSERT INTO myTest VALUES (1)	&& VFP don't visit THERMO here
>>INSERT INTO myTest VALUES (7)	&& VFP don't visit THERMO here
>>INSERT INTO myTest VALUES (0)
>>
>>SELECT 0
>>
>>SELECT * FROM myTest;
>>	WHERE (MOD(A,1000)#0 OR THERMO(A));
>>	INTO CURSOR rrr
>>
>>PROCEDURE THERMO(vValue)
>>	? "recno()=",RECNO(),"A=",vValue
>>
>
>Here's what I get.
>
> recno()= 1 A= 5
> recno()= 1 A= 5
> recno()= 1 A= 5
> recno()= 2 A= 0
> recno()= 3 A= 0
> recno()= 4 A= I'm null
> recno()= 5 A= 2
> recno()= 6 A= 1
> recno()= 7 A= 7
> recno()= 8 A= 0
>
>Two remarkable things:
>1 The first record is processed 3 times!
>2 Thermo() is processed EACH record, no matter the result of MOD(A,1000)#0. The A=0 lines should not have been in the list.
>
>I get the same result if there is no NULL record.
>
>The second result is what I am bringing to our attention. I actually thought that I would not be able to reproduce it with such simple code, but you did.

Found: Message #1041266
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform