Bowmore Posted December 18, 2007 Share Posted December 18, 2007 Does anyone know if AutotIt uses short circuit logic when testing for multiple conditions. For example in the following code: If foo1() = True and foo2() = True and foo3() = True Then Do Stuff EndIf If foo3() returned False would the processing jump to the first line after the EndIf statement without evaluating foo1() and foo2() or will foo1() and foo2() be always processed. Knowing the answer to this can be a great help when optimising condition checking within loops especially when you have some prior knowledge of the probability of each condition occurring. Thanks "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Valik Posted December 18, 2007 Share Posted December 18, 2007 Well, about 10 more lines of example code and you could have tested this yourself by just using simple functions with MsgBox() in them. But the answer is yes, AutoIt short circuits conditional statements. Link to comment Share on other sites More sharing options...
Bowmore Posted December 18, 2007 Author Share Posted December 18, 2007 Well, about 10 more lines of example code and you could have tested this yourself by just using simple functions with MsgBox() in them. But the answer is yes, AutoIt short circuits conditional statements.Thanks for answering my dumb question Valik. I realised shortly after posting that I could easily have check this out for myself. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Administrators Jon Posted December 18, 2007 Administrators Share Posted December 18, 2007 Erm, it does, but not as you posted in your example. It evaluates left to right in that line. If foo1 or foo2 were false then it would never get to call foo3. You seemed to be asking if foo3 was tested first? Deployment Blog:Â https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming:Â https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
ValeryVal Posted December 18, 2007 Share Posted December 18, 2007 btw about if evaluation.Sometimes I doubt real assignment will be carried out:dim $Var = 0if $Var = 10 then ; <some expression>endifand to be assured think about other form:dim $Var = 0if 10 = $Var then ; <some expression>endif The point of world view Link to comment Share on other sites More sharing options...
Valik Posted December 18, 2007 Share Posted December 18, 2007 btw about if evaluation.Sometimes I doubt real assignment will be carried out:dim $Var = 0if $Var = 10 then ; <some expression>endifand to be assured think about other form:dim $Var = 0if 10 = $Var then ; <some expression>endif While that is a fairly common practice in C\C++, it's not necessary in AutoIt. If statements do not perform assignment. That code does not translate to "assign $Var equal to 10, evaluate boolean value of 10" which it would do in C\C++. Link to comment Share on other sites More sharing options...
Bowmore Posted December 18, 2007 Author Share Posted December 18, 2007 Erm, it does, but not as you posted in your example. It evaluates left to right in that line. If foo1 or foo2 were false then it would never get to call foo3. You seemed to be asking if foo3 was tested first?Thanks Jon.Yes I had been making the wrong assumption that the parts would be evaluated right to left. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now