andyswarbs Posted March 3, 2006 Share Posted March 3, 2006 (edited) Can I ask fora point of clarification on the following: Version 1: $X=1 IF $X=0 and Z() Then Exit Endif My question "Is the function Z ever evaluated?". This is important since Z may be time-consuming. So a more laborious bit of code but safer, might be: Version 2: $X=1 If $X=0 Then If Z() Then Exit Endif endif But is the latter necessary? And is Version 1 a happenstance, or (my ideal answer) intentional in the language. I how safe am I in using version 1. Regards Andy Edited March 3, 2006 by andyswarbs Licensing.au3Extended _Max & _Min_MsgBoxExitVarious extensions to _GuiCtrl...Run Dos programs output into an array etc (Updated 19-Feb-06)Extensions to Array library, primarily in two dimensions (updated 20-Feb-06)Version dependency calculator, _IsVer1GEVer2User Management, answering some domain questions (updated 19-Feb-06, various bugfixes and new functions added)Extensions to registry manipulation, including a recursive search & replaceDelimited string library (updated 19-Feb-03, added _DelimListSort)String library extensionsTerminal Server supportFile libraryCommand line parser (added 18-Feb-06)(UDF homepage) (Scit4Au3 UserCallTips added 21-Feb-06) Link to comment Share on other sites More sharing options...
greenmachine Posted March 3, 2006 Share Posted March 3, 2006 Here are 3 tests I tried. It appears that Z() is never executed if $x does not pass the test. $X=1 IF $X=0 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() Sleep (5000) Return 1 EndFunc MsgBox (0, "exiting", "normally") $X=1 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() Sleep (5000) Return 1 EndFunc MsgBox (0, "exiting", "normally") $X=1 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() Sleep (5000) Return 0 EndFunc MsgBox (0, "exiting", "normally") Link to comment Share on other sites More sharing options...
Nuffilein805 Posted March 3, 2006 Share Posted March 3, 2006 Here are 3 tests I tried. It appears that Z() is never executed if $x does not pass the test. $X=1 IF $X=0 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() Sleep (5000) Return 1 EndFunc MsgBox (0, "exiting", "normally") $X=1 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() Sleep (5000) Return 1 EndFunc MsgBox (0, "exiting", "normally") $X=1 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() Sleep (5000) Return 0 EndFunc MsgBox (0, "exiting", "normally") there is a difference in z and Z if you try it with z() instead of Z() you will get inside the function $x = 0 if $x = 1 and z() then ... endif won't get inside the function so its up to you to choose how you write your code my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 3, 2006 Moderators Share Posted March 3, 2006 (edited) there is a difference in z and Z if you try it with z() instead of Z() you will get inside the function $x = 0 if $x = 1 and z() then ... endif won't get inside the function so its up to you to choose how you write your codeI'm not sure I understand what you mean a difference between Z() and z() in this post:MsgBox(0, '', Z()) Func z() Return 5 EndFunc MsgBox(0, '', y()) Func Y() Return 6 EndFunc Edit: Or even trying to reitterate that it does reach Z()... or z() ... $x obviously = 0 but Z() obviously would return 5, so if one of the 2 are true then it should give you the msgbox:$x = 0 If $x = 1 Or Z() = 5 Then MsgBox(0, 'Done', 'Reached Z() and it = ' & Z()) Func z() Return 5 EndFunc Edited March 3, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Administrators Jon Posted March 3, 2006 Administrators Share Posted March 3, 2006 Can I ask fora point of clarification on the following: Version 1: $X=1 IF $X=0 and Z() Then Exit Endif My question "Is the function Z ever evaluated?". No Z() isn't evaluated. 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...
greenmachine Posted March 4, 2006 Share Posted March 4, 2006 there is a difference in z and Z if you try it with z() instead of Z() you will get inside the function $x = 0 if $x = 1 and z() then ... endif won't get inside the function so its up to you to choose how you write your code Did you try it? It doesn't matter if it's small z or big z. $X=1 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() MsgBox (0, "in z", "z = Z") Return 1 EndFunc MsgBox (0, "exiting", "normally") I definitely got in z() there. Plus, if you use z() and Z() (which according to you would be different), you get this error: ERROR: Z() already defined. Func Z() ~~~~~~~~^$X=1 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() MsgBox (0, "in z", "z = Z") Return 1 EndFunc Func Z() MsgBox (0, "in big Z", "wtf") Return 1 EndFunc MsgBox (0, "exiting", "normally") This shows that AutoIt considers z() and Z() to be the same function, and this makes perfect sense since it's not case-sensitive. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 4, 2006 Moderators Share Posted March 4, 2006 Did you try it? It doesn't matter if it's small z or big z. $X=1 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Func z() MsgBox (0, "in z", "z = Z") Return 1 EndFunc MsgBox (0, "exiting", "normally") I definitely got in z() there. Plus, if you use z() and Z() (which according to you would be different), you get this error: $X=0 ; this one will not go to z() because $x = 0 IF $X=1 and Z() Then MsgBox (0, "in func", "whee") Exit Endif Your example shows $x = 1 as true which it is, so then it goes to Z(). Now if $x = 0 then it is false, so it never goes to Z() because the first inquiry isn't true so there is no need to go to z(). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
greenmachine Posted March 4, 2006 Share Posted March 4, 2006 A quote from myself when I first posted: Z() is never executed if $x does not pass the test. What I was showing in my last post is that when $x passes (and the script goes on to check z()), it doesn't matter if the functions match case or not. z() = Z(). That's all I'm saying. I made $x = 1 on purpose the second time around, so that I knew it would be going to Z(). I was hoping everyone would understand that the different tests were done on purpose.... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 4, 2006 Moderators Share Posted March 4, 2006 A quote from myself when I first posted: Z() is never executed if $x does not pass the test.What I was showing in my last post is that when $x passes (and the script goes on to check z()), it doesn't matter if the functions match case or not. z() = Z(). That's all I'm saying.I made $x = 1 on purpose the second time around, so that I knew it would be going to Z(). I was hoping everyone would understand that the different tests were done on purpose....I understood, I was reitterating your post . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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