Jump to content
Sign in to follow this  
Lope

AutoIt not parsing my IF statements

Recommended Posts

Lope

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Lope

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.

Share this post


Link to post
Share on other sites
Jos

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.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×