Shaarad Posted July 2, 2011 Share Posted July 2, 2011 Hello everyone again, I have some conditions to be processed by my program: Consider four conditions A,B,C,D each of which can have value either TRUE or FALSE decided by other parameters. now, I have to include an If..Then..EndIf condition as following: if A and B are both TRUE or C and D are both true ( or obviously all four are true ).. Then...if I write like the following, will it work according to its syntax ? if ($a=true and $b=true) or ($c=true and $d=true) then [some lines] endif It doesnt give any error as such during its compiling..but do the brackets make the program 'understand' what my real condition is ? Thanks. 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...
Developers Jos Posted July 2, 2011 Developers Share Posted July 2, 2011 Looks good ...Didn't it work when testing? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Shaarad Posted July 2, 2011 Author Share Posted July 2, 2011 (edited) Worked ! But I wanted some confirmation from you great MVP and DEV guys that our marvelous autoit language supports some complex conditions with such brackets in them.. Edited July 2, 2011 by Shaarad 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...
GEOSoft Posted July 2, 2011 Share Posted July 2, 2011 That is written properly but just to clarify your( or obviously all four are true ).It will never check if all four conditions are True. As soon as the first set of conditions is met it will stop there without any further checking because of the OR. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Shaarad Posted July 2, 2011 Author Share Posted July 2, 2011 OK agree with you GEOSoft, but I just wrote this experimental code: $var1=True $var2=False $result=False if (not ($var1=true and $var2=True)) or ($var1=false and $var2=true) or ($var1=true and $var2=false) then $result=True EndIf msgbox (0,"",$result) and the msgbox still returns the value as 'False' and not 'True' as expected.. 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...
Fubarable Posted July 2, 2011 Share Posted July 2, 2011 I guess it's a matter of code style preference, but the code would seem "cleaner" to me if written: If ($a And $b) or ($c And $d) Then ConsoleWrite("statement true!" & @CRLF) EndIf Link to comment Share on other sites More sharing options...
Developers Jos Posted July 2, 2011 Developers Share Posted July 2, 2011 You posted code returns true as expected because this is true: (not ($var1=true and $var2=True)) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
monoscout999 Posted July 2, 2011 Share Posted July 2, 2011 (edited) the brackets are wrong placed in that example. also you dont need to put the =true or the =false. and using OR means If ANY of the different conditions is true( or false if you use NOT)then..It seems that it work that way too.. Edited July 2, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Shaarad Posted July 2, 2011 Author Share Posted July 2, 2011 You posted code returns true as expected because this is true: (not ($var1=true and $var2=True))But I get the msgbox mentioning 'False'...sorry didn't get your point 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...
Developers Jos Posted July 2, 2011 Developers Share Posted July 2, 2011 But I get the msgbox mentioning 'False'...sorry didn't get your pointI get True with your code! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Fubarable Posted July 2, 2011 Share Posted July 2, 2011 I agree with Jos: the msgbox shows "true". Link to comment Share on other sites More sharing options...
Shaarad Posted July 2, 2011 Author Share Posted July 2, 2011 To monoscout999, As in my code, I have mentioned the the last condition which is true. Hence, according to my knowledge, the if ..endif condition is satisfied and the $result should now attain the value as True from its previous value False. But, it doesnot attain this and still giving the value as False only. 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...
Shaarad Posted July 2, 2011 Author Share Posted July 2, 2011 It actually WAS giving the value as False...but I had copied the code from my editor and pasted it here...and now when I read your replies, I copied the code from HERE and pasted it in my editor..and now it IS giving the value as true... How can it be possible ? 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...
Developers Jos Posted July 2, 2011 Developers Share Posted July 2, 2011 It actually WAS giving the value as False...but I had copied the code from my editor and pasted it here...and now when I read your replies, I copied the code from HERE and pasted it in my editor..and now it IS giving the value as true...How can it be possible ? Well, as I do not believe in miracles, there must be a difference between the code you tested with before and what is posted. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
monoscout999 Posted July 2, 2011 Share Posted July 2, 2011 maybe you erase the some "not" word. Link to comment Share on other sites More sharing options...
Shaarad Posted July 2, 2011 Author Share Posted July 2, 2011 It may be because I didn't save the changes in the code and it kept on running the code without my changes 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...
monoscout999 Posted July 2, 2011 Share Posted July 2, 2011 If you use SciTe the undo will do magic, i don´t know how many times you can do it, but it saves me a lot of times when i start to write in an existing file without noticed and when i run the script SciTe Saves the file overwriting the existing. about your first post. Hello everyone again, I have some conditions to be processed by my program: Consider four conditions A,B,C,D each of which can have value either TRUE or FALSE decided by other parameters. now, I have to include an If..Then..EndIf condition as following: if A and B are both TRUE or C and D are both true ( or obviously all four are true ).. Then...if I write like the following, will it work according to its syntax ?check first If All the variables are true, and later do the check for the groups, is important the order of the conditions to check if you use "OR". Correct way. $var1=True $var2=False $var3=True $var4=True $result=False if ($var1 and $var2 and $var3 and $var4) or ($var1 and $var2) or ($var3 and $var4) then $result=True EndIf msgbox (0,"",$result) Incorrect way. $var1=True $var2=False $var3=True $var4=True $result=False if ($var1 and $var2) or ($var3 and $var4) or ($var1 and $var2 and $var3 and $var4) then $result=True EndIf msgbox (0,"",$result) Link to comment Share on other sites More sharing options...
Shaarad Posted July 2, 2011 Author Share Posted July 2, 2011 Thanks a lot monoscout999 for providing such an elaborated explanations about the things which look simple, but have a deep meaning which must be considered to avoid confusions. Thanks again ! 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...
monoscout999 Posted July 2, 2011 Share Posted July 2, 2011 It will never check if all four conditions are True. As soon as the first set of conditions is met it will stop there without any further checking because of the OR.GEOSoft say it, not me... Link to comment Share on other sites More sharing options...
Fubarable Posted July 2, 2011 Share Posted July 2, 2011 If you use SciTe the undo will do magic, i don´t know how many times you can do it, but it saves me a lot of times when i start to write in an existing file without noticed and when i run the script SciTe Saves the file overwriting the existing. about your first post. check first If All the variables are true, and later do the check for the groups, is important the order of the conditions to check if you use "OR". Correct way. $var1=True $var2=False $var3=True $var4=True $result=False if ($var1 and $var2 and $var3 and $var4) or ($var1 and $var2) or ($var3 and $var4) then $result=True EndIf msgbox (0,"",$result) Incorrect way. $var1=True $var2=False $var3=True $var4=True $result=False if ($var1 and $var2) or ($var3 and $var4) or ($var1 and $var2 and $var3 and $var4) then $result=True EndIf msgbox (0,"",$result) I'm confused. Logically wouldn't just this be sufficient? if ($var1 and $var2) or ($var3 and $var4) then $result=True EndIf msgbox (0,"",$result)[/autoit] When would this statement ever be false and this statement true: ($var1 and $var2 and $var3 and $var4)? 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