← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #266772]: while not exists() or not exists(): does not seem to work

 

Question #266772 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/266772

RaiMan proposed the following answer:
I remember you said that:
false or false is false
true or false is true
false or true is true
true or true is true

this is for an or

like your 
while not exists(image1, 0) or not exists(image2, 0):
    wait(1)

shorter:
while condition1 or condition2:
    wait(1)

where
condition1 is  not exists(image1, 0)
condition2 is  not exists(image2, 0)

the while loops as long as 
 condition1 or condition2
evaluates to True

the last 3 cases in the little logic table.

hence the while only stops running if 
 condition1 or condition2
evaluate to False

which is only the case if BOTH condition1 AND condition2 evaluate to
False, which is only the case, if BOTH images are there.

--- But wouldn't that be the case for the if statement?
yes, the if statement has the same logic, but condition1 and condition2 are the opposite compared to the while, since we want to check wether we have to END the loop.
the while condition tells, wether the loop should continue to run.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.