Ask a Question

If Then Else Seems So Straight Forward

MarkSchofer
Frequent Contributor

If Then Else Seems So Straight Forward

This should be rather straight forward.  Project.Variables.Instance_Alias_V = "QAT2"
Still it blows through the IF statements as if they are all true. 

I did confirm with last result.

------------------------ 
def LoginIf():
import EnterQ1
import EnterQ2
import EnterQ5
Log.Message(Project.Variables.Instance_Alias_V, "")
if Project.Variables.Instance_Alias_V == "QAT1":
pass
Log.Message("QAT1", "")
#if LastResult == True:
#pass
#EnterQ1.EnterQ1()
if Project.Variables.Instance_Alias_V == "QAT2":
pass
Log.Message("QAT2", "")
#EnterQ2.EnterQ2()
if Project.Variables.Instance_Alias_V == "QAT5":
pass
Log.Message("QAT5", "")
#EnterQ5.EnterQ5()

I commented out the calls to login scripts

4 REPLIES 4
hkim5
Staff

Re: If Then Else Seems So Straight Forward

i tried your original code block (which worked fine for me), and tried commenting out the "pass" (which didnt seem necessary) which also worked, and then used elif instead if reoccuring if's and that also worked for me. 

 

so i don't know whats happening with your system, but to me given that the project variable is (for example) QAT2, my end result prints that value twice

 

 

def LoginIf():
  
  Log.Message(Project.Variables.Instance_Alias_V, "")
  if Project.Variables.Instance_Alias_V == "QAT1":
    #pass
    Log.Message("QAT1", "")
  #if LastResult == True:
  #pass
  #EnterQ1.EnterQ1()
  elif Project.Variables.Instance_Alias_V == "QAT2":
    #pass
    Log.Message("QAT2", "")
  #EnterQ2.EnterQ2()
  elif Project.Variables.Instance_Alias_V == "QAT5":
    #pass
    Log.Message("QAT5", "")
  #EnterQ5.EnterQ5()

 

 

 

hkim5_0-1626807024263.png

 

Best,
Justin Kim
MarkSchofer
Frequent Contributor

Re: If Then Else Seems So Straight Forward

If they were handing out great parking spaces you would have earned one.

 

Well done

hkim5
Staff

Re: If Then Else Seems So Straight Forward

im not sure what that means.

were you expecting a different behavior from your code?

if the product is not behaving as expected, please give some more info here 

Best,
Justin Kim
MarkSchofer
Frequent Contributor

Re: If Then Else Seems So Straight Forward

It was exactly what I was looking for.

cancel
Showing results for 
Search instead for 
Did you mean: