← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #189649]: Try a lot of possibility of code

 

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

RaiMan proposed the following answer:
You might want to stop the process at some time within doSomething().

Here is a version for that (only the relevant part):

# the recursive function
def nextLetter(i):
    global running
    for b in abc:
        word[i] = b
        for i1 in range(i+1, max):
            nextLetter(i1)
            if not running: return
        w = ""
        for x in word: w += x
        # next word ready
        if not doSomething(w):
            running = False
            return

# here goes what you want to do with the word
def doSomething(w):
    f.write(w+"\n")
    if some_condition: return False # decision to stop the process
    return True

# here is the main workflow
# chose appropriate filename
f = file("/Users/rhocke/out.txt", "w")
running = True
for i in range(max):
    nextLetter(i)
    if not running: break 
f.close()

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