about Flow Control

Asked by pipboy

   I encounter a problem about flow control
   please at look my code;

   My situation : A>1>2>3>A or A>1>2>1> X

   Is there any way i can change as below :
   A>1>2>1>2>1>2>1>... (Reason by analogy)... >3>A

=============================================

for i in range(n):

    if exists("error.png"):
     exit()

    openApp("test.exe")

    if exists( "progarm_already_running.png", 10): ----- A
        click ("Yes")
         .......
         .......
         .......

    if exists("device in use,pls try again.png",10): --- 1 ----- B
    # If device.png was displayed ,Indicated that limit test is starting

         click("OK") --- 2 ----- B
         # for keeping limit test , click OK of the device.png

         click ("Play") --- 3 ----- B
         #play a sound and back for-loop (A)

=============================================

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 I understand your > notation right, your current code is either

A > 1 > 2 > 3 > A (no error, device.png exists)

or

A > 1 > X (error, X means exit ???, device.png does not exists)

If you want to have:

A>1>2>1>2>1>2>1>...

you need another loop and a condition, that ends this loop

e.g.
for i in range(n):
    # some code
    # A
    while some_condition:
        # 1
        # 2

or

for i in range(n):
    # some code
    # A
    while True:
        # 1
        if some_condition: break
        # 2
        if some_other_condition: break

Revision history for this message
pipboy (peace03) said :
#2

A > 1 > 2 > 3 > A (no error, device.png exists, continue next loop)

or

A > 1 > X (error, X means fail, device.png exists but not click OK)

I will try while-loop
thanks for your fast response :-)

Revision history for this message
pipboy (peace03) said :
#3

Thanks RaiMan, that solved my question.