Evaluation of complex conditions
livfoss at mac.com
Thu Oct 6 15:01:19 CDT 2011
Yes, in any 'and' where the first condition is false, then the second condition is not evaluated; similarly in any 'or', if the first condition is true, the second isn't evaluated. Parentheses alter the order of evaluation as others have said.
It's easy to prove this by writing a script where the thing generating your condition ('a' in your example) is a function - you can then make the function have a side effect. As sample function might be
put "condition returning true has been invoked;" after whatHappened
you then write an 'if' statement which at some point in the logic calls ReturnsTrue(), and when you look at the global 'whatHappened' you will see whether the evaluation reached that point or not...
On 5 October 2011 16:25, Pete <pete at mollysrevenge.com> wrote:
> No, I mean:
> If a is true then
> if (b is true or c is true) then
> do whatever
> end if
> end if
> I'm pretty sure if a was false, the second condition wouldn't be evaluated.
> But you raise an interesting point - in your example, does the condition
> inside the parens truly get evaluated first?
> Molly's Revenge <http://www.mollysrevenge.com>
More information about the use-livecode