Running Script from middle

Asked by Venkata Sandeepu Lade

Can we run sikuli script from middle?

Say if I have 100 lines of script, I want to run the script from 50 th line to 100th line

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

if you want to do this manually in the IDE, the put the lines not needed for this run in a block comment (3 apostrophes before and after):

"""
# the following lines up to the
# end of block comment
# will be ignored
.... some lines follow
"""
# from here will be executed
click()
wait()
.... some lines follow

If you want to do this programmatically, you might make the first 50 statements dependent from a condition, that has to be met:

if condition:
    click() # only executed if condition is met
    # mind indentation
# the following statements will be executed anyway
click()
wait()

The most flexible way is to put lines of code, that for some logical entity into def()'s and run them as needed:

def first_part():
    click() # only executed if first_part is called
    # more lines follow, mind indentation

def second_part():
    click() # only executed if second_part is called
    # more lines follow, mind indentation

# now we use the def()'s
first_part() # all statements of first_part are executed
second_part() # all statements of second_part are executed

This can be combined with the above if construct.

Python (the scripting language of Sikuli using the IDE) has many more options ;-)

Revision history for this message
Venkata Sandeepu Lade (venkatasandeep-lade) said :
#2

Raiman, Thanks for clarifying my question

Revision history for this message
Venkata Sandeepu Lade (venkatasandeep-lade) said :
#3

Thanks RaiMan, that solved my question.