Jump to content
Sign in to follow this  

Version 3.102

Recommended Posts

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.")

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?


Share this post

Link to post
Share on other sites

This code is correct:

If $PositivePulse <> "yes" OR $PositivePulse <> "no" Then

If $PositivePulse <> "yes"


If $PositivePulse does not equal "yes"

If $PositivePulse <> "no"


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 by SlimShady

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

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.


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 by herewasplato


Share this post

Link to post
Share on other sites

The two parts of the If expression are taken independently. For example, this structure allows this:

If $x = 3 OR $y < 0 Then

as well as

If $x = 3 OR $x = 8 Then

Either 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 Nuttall
Nuttall 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...

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...