Jump to content

AutoIt not parsing my IF statements


Lope
 Share

Recommended Posts

AutoIt doesn't like the way I do If Statements. If someone can tell me how I can get stuff like this on one line that would be great.

;this will not parse correctly
    If FileExists($path_startmenu_client_me)  Then
        If DirRemove($path_startmenu_client_me) Then install_log("StartMenu Deleted " & @UserName & " " & $path_startmenu_client_me) Else install_log("StartMenu Delete Failed " & @UserName & " " & $path_startmenu_client_me,"Failed to delete old startmenu items for " & @UserName & @CRLF & "Setup will now end.")
    EndIf

;if I separate it into multiple lines it parses fine...
    If FileExists($path_startmenu_client_me)  Then
        If DirRemove($path_startmenu_client_me) Then
            install_log("StartMenu Deleted " & @UserName & " " & $path_startmenu_client_me)
        Else
            install_log("StartMenu Delete Failed " & @UserName & " " & $path_startmenu_client_me,"Failed to delete old startmenu items for " & @UserName & @CRLF & "Setup will now end.")
        EndIf
    EndIf
Edited by Lope
Link to comment
Share on other sites

  • Developers

AutoIt doesn't like the way I do If Statements. If someone can tell me how I can get stuff like this on one line that would be great.

Your second example is the one and only correct way. What is the need for putting it on one line?

Jos :idea:

Edited by Jos

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

Thanks Jos.

I prefer shorter looking code :idea:

I'd love it if AutoIt had an option to use {} instead of newlines and EndBlah's :)

C style is way better. Maybe I'm just sick of VB code, been coding VB5/6 for 13 years hehe.

Link to comment
Share on other sites

  • Developers

Thanks Jos.

I prefer shorter looking code :idea:

I'd love it if AutoIt had an option to use {} instead of newlines and EndBlah's :)

C style is way better. Maybe I'm just sick of VB code, been coding VB5/6 for 13 years hehe.

Putting code on one line doesn't per-say make it "shorter" unless you mean less lines. It does however make it much harder to read when it contains an "Else".

So one line IF's are fine as long as they only contain a THEN.

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

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