herewasplato Posted August 17, 2004 Posted August 17, 2004 The code below worked using version 3.101 but not with version 3.102. $PositivePulse = "yes" If $PositivePulse <> "yes" OR "no" Then MsgBox (0, "ERROR", "PositivePulse must be set to either yes or no." & @CR &_ "It is currently set to " & $PositivePulse & @CR &_ "I'm going to exit now.") EXIT EndIf I have also tried: If $PositivePulse <> "yes" OR $PositivePulse <> "no" Then Version 3.102 always returns the msgbox... What changed and/or what am I doing wrong? [size="1"][font="Arial"].[u].[/u][/font][/size]
SlimShady Posted August 17, 2004 Posted August 17, 2004 (edited) This code is correct: If $PositivePulse <> "yes" OR $PositivePulse <> "no" Then If $PositivePulse <> "yes" means If $PositivePulse does not equal "yes"If $PositivePulse <> "no" means If $PositivePulse does not equal "no"The script reads the statement and sees that the left part is false and the right part (of the statement) is true, so the msgbox is displayed. I understand what you're saying: It's like this sentence in English: I eat and/or watch TV. (what I know) Programming has 3 operators : AND, NOT, OR OR functions like a light switch. It's either on OR off, not both. In the previous version it was a bug that both cases could be true/false. But I would like to use an operator that functions like the English "and/or". I can't think of a name for it, though. Edited August 17, 2004 by SlimShady
Valik Posted August 17, 2004 Posted August 17, 2004 The reason it worked before is due to how strings worked pre-102. Before, a string would equate to 0, now, a string is 1 if it is something and 0 if it is empty (""). What was happening was, you had a major bug in your code, but due to the old behavior of how strings returned a value, the code appeared to work. In the new version, however, with the new way string's return a value, the bug in your code showed itself.
herewasplato Posted August 17, 2004 Author Posted August 17, 2004 (edited) Thanks... that explains it. That If statement was just one of several that I threw in to check for my own typos when setting values for the variables. Using: If $PositivePulse <> "yes" And $PositivePulse <> "no" Then ...seems to do what I wanted... I just did not want to set the variable value to yesss Thanks again for pointing out the correct syntax and the change in versions. Edited August 17, 2004 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Nutster Posted August 19, 2004 Posted August 19, 2004 The two parts of the If expression are taken independently. For example, this structure allows this:If $x = 3 OR $y < 0 Thenas well as If $x = 3 OR $x = 8 ThenEither of the independant conditions can be true for the whole thing to be considered true. If both are true then the result of the OR will still be true. The type of Or that checks that only one of the arguments is true is called an exclusive or. AutoIt does not have this an operator. But you can check the BitXor function for an explaination. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
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