Returns and continuation in the script

Asked by fordox

Please, tell me how to make a script to work from the start, if the value of the variable is equal to 3.

Example:

script start point

m = random.randint(1, 3)
if m == 1:
    type("some text"+Key.ENTER)
if m == 2:
    continue script
if m == 3:
    return to script start point and new initialization variable m

I did not get to use the break or Continuе. How to get back to the beginning of the script or to a specific line or restart script?

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

while True: # some endless loop
    m = random.randint(1, 3)
    if m == 1:
        type("some text"+Key.ENTER)
    if m == 2:
        break # jumps after the end of the loop
    if m == 3:
        continue # jumps to the loop intro (while True:)
# here your script continues

Revision history for this message
fordox (neveroid) said :
#2

Thanks RaiMan, that solved my question.