sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #17062
Re: [Question #224366]: Reuse of code through import
Question #224366 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/224366
Description changed to:
Hello,
I have several primary scripts, portions of which repeat many times from script to script. I want to modularize the repetitive portions, turn them into their own individual scripts, and then call them from the primary scripts. The obvious benefit is to make the code more flexible, more efficient and easier to maintain.
But...
I am having difficulty implementing what I think should be a fairly easy
programming concept. Below is a sample of what I'm generally trying to
do using the import function. In this case, I have four separate
scripts all of which exist in the same folder (Main_Script,
Sub_Script_A, Sub_Script_B, Sub_Script_C). Main_Script calls sub-
script-a, and then goes into a loop and calls sub-script-b and sub-
script-c.
The behavior I'm observing is that sub-script b goes into a loop. I was
expecting sub-script b to complete and then execute the next line of
code in the main script.
I hope this provides enough details to communicate the essence of my
problem. Thanks in advance for any assistance.
Main_Script
#<start>
Sub_Script_A
for x in xrange(0,100):
Click(some image)
Type(some text)
Etc...
import Sub_Script_B
reload(Sub_Script_B)
Click(some image)
Type(some text)
Etc...
import Sub_Script_C
reload(Sub_Script_C)
Click(some image)
Type(some text)
Etc...
#<end>
Sub_Script_A
#<start>
from sikuli import *
Click(some image)
Type(some text)
Etc...
#<end>
Sub_Script_B
#<start>
from sikuli import *
Click(some image)
Type(some text)
Etc...
#<end>
Sub_Script_C
#<start>
from sikuli import *
Click(some image)
Type(some text)
Etc...
#<end>
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.