For and If Statement

Asked by Ronron

surf_ray = "C:\\DingDong\\ding_0.9.0.1603011\\ding.exe -scheduleanalysis -IDB \"D:\\Analyzer\\11-6592-H.db\" -AN \"SR\" -PGN \"Default\" -SI 5"
distn_thread = "C:\\DingDong\\ding_0.9.0.1603011\\ding.exe -scheduleanalysis -IDB \"D:\\Analyzer\\11-6592-H.db\" -AN \"distnthrd\" -PGN \"Default\" -SI 5"
net_result = ["1459454324185.png","1459454281825.png"]

Analyzers = [surf_ray,distn_thread]
results =["result-1.png", "result-1.png"]

for Analyzer,result in zip(Analyzers,results):
    openApp(Analyzer)
    wait(Pattern("1459446866629.png").similar(0.41).targetOffset(166,62),FOREVER)
    click (Pattern("1459446866629.png").targetOffset(166,62))
    wait( "1458766157226.png",FOREVER)
    waitVanish( "1458766157226-1.png",FOREVER)
    wait(10)
    find(result)
    if net_result == result:
        click(Pattern("1458766726732.png").targetOffset(307,-176))

in the program above after the first loop I see the "result" which is a pdf file I now want the image in the net_result to be checked on the pdf image and if they match then do the click. I feel I am doing something wrong on the IF statement.

Also can I use 3 list like-- for Analyzer,result,net_count in zip(Analyzers,results,net_counts):
I get a error expecting RBSTACK

Question information

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

--- if net_result == result:
- result in that moment contains the current string from results according to the current for loop state
- net_result is a list
... hence this is always false

what is your intention here?

--- for Analyzer,result,net_count in zip(Analyzers,results,net_counts):
... should work
https://docs.python.org/2/library/functions.html#zip
... but be aware:
changes of net_count inside the loop does not influence the content of net_counts!

Revision history for this message
Ronron (rohitsakp) said :
#2

So this is what I am trying to do
 the openApp(analyzer)-- opens an app which kicks in an analyzer
i get the result
the result is a pdf report which has a count number called NET COUNT
I want to compare this NET COUNT with the image i saved in net_count and both should be same.

Revision history for this message
Ronron (rohitsakp) said :
#3

ALSO i did the following changes to the initial program
    find(result)
    for net_result,result in zip(net_results,results):
        if net_result == net_result:
            click("1459458931766.png")
        else:
            print"NotOKAy"

but what this does is it runs checks if net_result ==net_result and performs the first click. then randomly goes and performs another click without the 1st for loop completed

Revision history for this message
Ronron (rohitsakp) said :
#4

never mind i just had to use

break

Sorry I a new to programming