← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #203727]: calling functions between multiple files

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
good, that it did not work ;-)

This would give an endless loop, since I cannot see, that recursiveness
is implemented in your script.

when running in IDE, this should work:

# sarkoth.sikuli

from sikuli import *
import general # comment 1
reload(general) # comment 1
from general import *

def main():
    do things
     retVal = leave() # comment 3

    else:
        retVal = leave()

runs=0
while runs>=0:
    main()

# general.sikuli

from sikuli import *

def leave():
    type("t")
    return something # comment 2


That's all, if both scripts are in the same folder.
If not, you have to set sys.path accordingly (see docs)

-- comment 1
These 2 statements are only needed, if you run the main script (sarkoth) in the IDE and in parallel make changes to subs (general). So you can have open all scripts in the IDE and make concurrent changes.

-- comment 2
at this point leave() is ended and jumps back to the line after it was called in main(). something might be a return value, that can be checked in main.

-- comment 3
we store the return value of leave(), so we can use it later (e.g. to check,wether we should terminate our script or do any other action.

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