Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AND and OR evaluations in conditional statements
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00206066
Message ID:
00206988
Views:
16
Jim,

You are exactly right. It is VFP's optimization of logical expressions that keeps the full logical expression from being evaluated. If you put trackable functions in that all return "unoptimizeable" values you can see that VFP does use the proper precedence.

? f1() or t1() and t2() and f2() or f3() or f4() or ( t1() and ( f1() or t2() ) )

function f1()
? program()
return .f.

function f2()
? program()
return .f.

function f3()
? program()
return .f.

function f4()
? program()
return .f.

function t1()
? program()
return .t.

function t2()
? program()
return .t.


>It is my understanding that precendence mean sthat one orperation will be performed before another at the same level of parens. That would mean that if an OR and a AND appeared at the same parenthetical level the AND would be evaluated first. However, my testing indicates clearly that the expressions are evaluated from left to right regardless of the position of the and or the or.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform