>>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?
>
>I suppose that within a SQL command different rules apply, what with Rushmore Optimization. For example, in one particular case Visual FoxPro might decide that it is more efficient to evaluate the right-hand member first, because it is Rushmore-Optimizable. In any case, I wouldn't count on the right-hand expression not being evaluated within a SQL command (on the other hand, I would trust VFP to do shortcut boolean evaluation in most other cases).
>
>If shortcut boolean evaluation is important in this case, you might move the entire combined expression to a UDF, or change it to an IIF().
Great, your tip to use IIF did help!
WHERE IIF(MOD(A,1000)=0,THERMO(A),.T.)
And that's the most important thing for me now. Remains the quest whether the rule is not valid inside a SQL command. If that is indeed the case, then it should be documented, at the least.
Groet,
Peter de Valença
Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.