← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #680253]: Looping infinite with observer

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
What you are missing is some basic understanding of scripting and here especially with Python.
Every scripting language has some regular constructs, that follow systematic rules, which is usually called its syntax.
Syntax is nothing that can be handled like art work or with creativity, it has simply to be learned.

There are good tutorials in the net, where you can learn the basic
syntax elements.

Sikulix is only a feature set, that can be used in various (currently mostly Java aware) scripting and/or programming environments.
Hence the SikuliX docs only try to explain the SikuliX features. Due to historical reasons the examples are mostly in Python, which is the most used variant. But the SikuliX docs cannot help you to learn scripting or even Python. 

I now give you some comments to your example:

--- while ("1555266479704.png",FOREVER):
while expects a condition-expressions which either evaluates to False or True.
If True, the loop will start again, otherwise it is stopped (code continues after the while block).

("1555266479704.png",FOREVER) evaluates to a tuple (non-modifyable
list), which always evaluates to True.

So the easiest way, to have an endless loop:

while True:

endless loops should always have some code inside, that allow, to end
the loop in special situations.

usually:
if someCondition:
    break

Otherwise you have to kill the scriptrun from outside, which should not
be a general measure.

--- But when he doesnt find it , it closes the script.
find("1554910622874.png")
throws a FindFailed, if not handled (being the case here), which stops the script with an appropriate error message.
About FindFailed and how to handle it, there is a chapter in the docs.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.