Jump to content

Nested If statements


Denis
 Share

Recommended Posts

It works neither in this form:

SetError(0)

FileReadLine($File1)

If @error Then

SetError(0)

FileReadLine($File2)

If @error Then FinalMessage("Equal")

Else FinalMessage("Not equal - 2 is longer")

EndIf

FinalMessage("Not equal - 1 is longer")

nor in this:

SetError(0)

FileReadLine($File1)

If @error Then

SetError(0)

FileReadLine($File2)

If @error Then FinalMessage("Equal")

EndIf

Else FinalMessage("Not equal - 2 is longer")

EndIf

FinalMessage("Not equal - 1 is longer")

nor in this one:

SetError(0)

FileReadLine($File1)

If @error Then

SetError(0)

FileReadLine($File2)

If @error Then

FinalMessage("Equal")

else

EndIf

Else FinalMessage("Not equal - 2 is longer")

EndIf

FinalMessage("Not equal - 1 is longer")

It works as this:

SetError(0)

FileReadLine($File1)

If @error Then

SetError(0)

FileReadLine($File2)

If @error Then

FinalMessage("Equal")

Else FinalMessage("Not equal - 2 is longer")

EndIf

EndIf

FinalMessage("Not equal - 1 is longer")

but I still don't like the entire matter - it may occur again in much worse state.

//Func FinalMessage (Const $MessageName)

// MsgBox(0,$MessageName,TimerDiff($timerstart))

// WinWait($MessageName)

// Exit

//EndFunc

Link to comment
Share on other sites

You cannot add code on the same line after the Else keyword.

SetError(0)
FileReadLine($File1)
If @error Then
    SetError(0)
    FileReadLine($File2)
    If @error Then FinalMessage("Equal")
Else
    FinalMessage("Not equal - 2 is longer")
EndIf
FinalMessage("Not equal - 1 is longer")

;nor in this:

SetError(0)
FileReadLine($File1)
If @error Then
    SetError(0)
    FileReadLine($File2)
    If @error Then
        FinalMessage("Equal")
    EndIf
Else
    FinalMessage("Not equal - 2 is longer")
EndIf
FinalMessage("Not equal - 1 is longer")

;nor in this one:

SetError(0)
FileReadLine($File1)
If @error Then
    SetError(0)
    FileReadLine($File2)
    If @error Then 
        FinalMessage("Equal")
    else
        ;something here
    EndIf
Else
    FinalMessage("Not equal - 2 is longer")
EndIf
FinalMessage("Not equal - 1 is longer")

;It works as this:

SetError(0)
FileReadLine($File1)
If @error Then
    SetError(0)
    FileReadLine($File2)
    If @error Then 
    FinalMessage("Equal")
    Else
        FinalMessage("Not equal - 2 is longer")
    EndIf
EndIf
FinalMessage("Not equal - 1 is longer")

;but I still don't like the entire matter - it may occur again in much worse state.

;Func FinalMessage (Const $MessageName)
; MsgBox(0,$MessageName,TimerDiff($timerstart))
; WinWait($MessageName)
; Exit
;EndFunc

:lmao:

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