Sign in to follow this  
Followers 0
c.haslam

True and False not for use in expressions

6 posts in this topic

The help for True and False says: "These keywords should not be used in expressions as AutoIt will not detect this 'misuse' and the results will be unpredictable". What precisely is meant by this?

The example is:

$bool= False

if NOT $bool = true Then Msgbox(0,"Bool comparison", "OK")

Isn't $bool = true an expression?

Or is the help saying that

CODE
if FileCopy("C:\old\*.*", "C:\new\") = True then
won't work because FileCopy() returns 1 or 0?

...chris


...chris

Share this post


Link to post
Share on other sites



It's referring to context where it doesn't make sense. AutoIt won't reprimand you in those cases. For example:

$a = 1 + True

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

c.haslam

won't work because FileCopy() returns 1 or 0?

Works fine for me:

if FileCopy("c:\Help.htm", "D:\", 1) = True then MsgBox(0, "", "True")

Check path`s existing.

Edited by rasim

Share this post


Link to post
Share on other sites

c.haslam

Works fine for me:

if FileCopy("c:\Help.htm", "D:\", 1) = True then MsgBox(0, "", "True")

Check path`s existing.

Keep in mind, explicitly testing booleans against a literal True or False is stupid. It does not need done and just clutters the code with needless crap.

Share this post


Link to post
Share on other sites

My quibble is with the help file. Perhaps the wording could be improved. Is True equal to 1 and False to 0? Are "If 1 then ..." and "If True then" equivalent?

...chris


...chris

Share this post


Link to post
Share on other sites

My quibble is with the help file. Perhaps the wording could be improved. Is True equal to 1 and False to 0? Are "If 1 then ..." and "If True then" equivalent?

...chris

Zero being the only "False" statement, as less than or greater than zero will be considered a "True" statement.

So when using a boolean statement, you need nothing more than If ($bool) Then or If (Not $bool) Then... Need not concern yourself with actual integer values.


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.

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  
Followers 0