Boolean expressions are evaluated sequentially
Posted: Fri Dec 11, 2020 6:42 pm
Has this been discussed before?
I am building a CAD-like drawing program in LC, and as a convenience I made a gadget to allow me to hide graphics if I simply click on them with the optionKey. I want only graphics to hide. So I tested three conditions:
In version two the condition "and the mouseControl <> empty" comes third, after the other two, as opposed to second, between the other two, in version one. That version fails with "no target found" if I click on empty card space,
The card object is not a mouseControl, the function returning empty.
I assume this means that each condition is evaluated sequentially, and clicking on empty space throws an error since the test for graphic "fails" before the empty result from the function "fails".
The pecking order matters, even though each condition on its own is identical between the two versions. I do not see a reason for this at all.
Expected behavior?
Craig
I am building a CAD-like drawing program in LC, and as a convenience I made a gadget to allow me to hide graphics if I simply click on them with the optionKey. I want only graphics to hide. So I tested three conditions:
Code: Select all
if the optionKey is down and the mouseControl <> empty and the name of the mouseControl contains "graphic"
then hide the mouseControl --works fine
--if the optionKey is down and the name of the mouseControl contains "graphic" and the mouseControl <> empty
--then hide the mouseControl --fails
The card object is not a mouseControl, the function returning empty.
I assume this means that each condition is evaluated sequentially, and clicking on empty space throws an error since the test for graphic "fails" before the empty result from the function "fails".
The pecking order matters, even though each condition on its own is identical between the two versions. I do not see a reason for this at all.
Expected behavior?
Craig