Jump to content

Which Format Is Correct?


Guest rathore
 Share

Recommended Posts

Guest rathore

i'd used this in last version that i used (3.0.100)

If $TOREAD = "" AND If FileExists(@TempDir&"\readme.txt") Then $TOREAD = @TempDir&"\readme.txt"

now with the Au3withGUI version this has changed to:

If $TOREAD = "" AND FileExists(@TempDir&"\readme.txt") Then $TOREAD = @TempDir&"\readme.txt"

Which is the one I should stick to for future compatability?

(and i'm damn sure there was one more changed that i'd to do, which skips me right now) :whistle:

Link to comment
Share on other sites

If the first way worked at all and didn't cause a crash or error, then it may of been part of the bug Jon fixed in the latest unstable (If it was part of that bug, it should of crashed AutoIt, though, unless that was never executed...), which is what the latest AutoIt-GUI version is based on.

Link to comment
Share on other sites

If $TOREAD = "" THEN If FileExists(@TempDir&"\readme.txt") Then $TOREAD = @TempDir&"\readme.txt"

or

If $TOREAD = "" AND FileExists(@TempDir&"\readme.txt") Then $TOREAD = @TempDir&"\readme.txt"

I like second version, but revised first version should work as well.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Guest rathore

thanx all for clarifying....

scriptkitty: i've just a hunch that the usage that skipped my mind at the time of posting the message (read main thread) is somehow related to "If $TOREAD = "" THEN If"

but its okay now... i'll use the 2nd format for future!!

Link to comment
Share on other sites

aye, an AND statement can be done with if, an OR can be done with else, but it is a lot cleaner to use AND and OR.

It is good to know diferent approaches though, like more tools on the job.

; consider $x is an integer
if $x>1 then if $x<3 then msgbox(1,"$x is","2"); AND statement

if $x>2 then
msgbox(1,"$x is not","2"); OR statement
else
if $x<2 then msgbox(1,"$x is not","2")
endif

Select
  Case $x>2
    msgbox(1,"$x is not","2")
  Case $x<2
    msgbox(1,"$x is not","2")
  Case Else 
    msgbox(1,"$x is","2") 
endselect

sleep(2000)

;Better way to express the same thing
if $x>1 AND $x<3 then msgbox(1,"$x is","2") 
if $x>2 OR  $x<2 then msgbox(1,"$x is not","2")

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Guest rathore

thanx for the choices...

but as u said

;Better way to express the same thing

if $x>1 AND $x<3 then msgbox(1,"$x is","2")

if $x>2 ORĀ  $x<2 then msgbox(1,"$x is not","2")

i'm going to stick with these, unless something requires spl handling.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...