Linking script back again after else

Asked by Poh Wei Pin

Example Script: [Roughly What i wrote]

If Exists("Picture A")
  Click("Me 1")
  Click("Me 2")

Else
   Click("Him1")
   Click("Him 2")

Now Here comes my problem....
Is there anyway to link back to my script again after the else??

[What i actually wanted]

If Exists("Picture A")
  BACK TO HERE <--------------
  Click("Me 1") |
  Click("Me 2") |
                                                        |
Else |
   Click("Him1") |
   Click("Him 2") |
                                                        |
 CONTINUE BACK TO EXISTS >-|

More Examples:

In CMD language,
I wrote this:
If Exists("Picture A")
  :Blah
  Click("Me 1")
  Click("Me 2")

Else
   Click("Him1")
   Click("Him 2")
   :Blah [Linking Blah to the top Blah]

Please help me thank you!

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

Poh Wei Pin, your logic are not that clear to me (you put label "Blah" after If/Exist statements, not before it to have If run again).

The simple answer for you question is "Yes", you can execute If forever with While infinite looping, see at
 http://www.tutorialspoint.com/python/python_while_loop.htm example "The Infinite Loop"

Like that:
while True :
 If Exists("Picture A")
   Click("Me 1")
   Click("Me 2")

 Else
    Click("Him1")
    Click("Him 2")

To break the infinite loop when needed you might use Break Python operator.

Can you help with this problem?

Provide an answer of your own, or ask Poh Wei Pin for more information if necessary.

To post a message you must log in.