Jump to content

If, Then, Else, EndIf Error?


Recommended Posts

I am trying to get a simple form to show and then quit with the OK button but keep getting the following error:

Func OKButton()

Error: "If" statement has no matching "EndIf" statement.

The code I have is:

#include <includes\GUIConstants.au3>

If 1 = 2 Then
    Exit
Else
    Opt("GUIOnEventMode", 1)            ; Change to OnEvent mode
    $frmPatternError = GUICreate("Pattern Error!!", 344, 101, 193, 115)
    $lblLabel1 = GUICtrlCreateLabel("Pattern Does Not Match", 72, 8, 197, 24)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $lblLabel2 = GUICtrlCreateLabel("Please contact Prod Eng", 8, 32, 327, 24)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $btnOK = GUICtrlCreateButton("OK", 128, 64, 75, 25, 0)
    GUICtrlSetOnEvent($btnOK, "OKButton")
    GUISetState(@SW_SHOW)
    
    While 1
        Sleep(1000)
    WEnd
    
    Func OKButton()
        Exit
    EndFunc
EndIf

nyone help as I can't seem to get this working. I know it should be an easy fix - just can't see it.

Thanks.

Pete.

Link to comment
Share on other sites

#include <GUIConstants.au3>

If 1 = 2 Then
    Exit
Else
    Opt("GUIOnEventMode", 1)            ; Change to OnEvent mode
    $frmPatternError = GUICreate("Pattern Error!!", 344, 101, 193, 115)
    $lblLabel1 = GUICtrlCreateLabel("Pattern Does Not Match", 72, 8, 197, 24)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $lblLabel2 = GUICtrlCreateLabel("Please contact Prod Eng", 8, 32, 327, 24)
    GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
    $btnOK = GUICtrlCreateButton("OK", 128, 64, 75, 25, 0)
    GUICtrlSetOnEvent($btnOK, "OKButton")
    GUISetState(@SW_SHOW)
EndIf

While 1
    Sleep(1000)
WEnd

Func OKButton()
    Exit
EndFunc

Why not just use a msgbox(), though?

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