← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #225014]: sequential numbers

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
put all "scripts" (which in fact are script lines) in a def() and call
it with the actual number:

def avengers(n):
    type("avengers"+str(n))
    bunch of other scripts

avengers(1) # will run the above script lines as avengers1
avengers(2) # will run the above script lines as avengers2
avengers(3) # will run the above script lines as avengers3

Mind the indentation in the def. In doubt look faq 1800

even more scripting like:

for n in range(5):
    avengers(n+1)

which sequentially calls the def with the numbers 1, 2, 3, 4, 5
(range(5) evaluates to the numbers 0 to 4 one after the other)

some info on loops: faq 1437

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