Jump to content

Recommended Posts

Posted

I have created a GUI and I am using OnEventMode. This GUI allows the user to browse for a directory or specifiy it manually, and also browse for the location of the results file or specify it manually. After the user presses the Go button I start checking for valid file paths inside my "Go" function. If there is invalid input I want the program to start again from scratch, however it seems to not re-enter the GUI function I have created and then pick right back up where it left off. Here's sample code...

#include <file.au3>
#include <GuiConstants.au3>
CGGui()

Func CGGui()
...
...
...
EndFunc

Func Go()

$logdir=GuiCtrlRead($Input_logdir)
$resultfile=GuiCtrlRead($Input_results)

If FileExists($logdir)=0 Then
    MsgBox(4096,"Error","Specified Logs directory does not exist!")
    Restart()
EndIf

If $resultfile="" Then
    MsgBox(4096,"Error","Results file not specified!")
    Restart()
EndIf

$resultfile = FileOpen ( $resultfile, 2)
If $resultfile=-1 Then
    MsgBox(0,"Error","Unable to open/create specified results file!")
    Restart()
EndIf

EndFunc

Func Restart()
    MsgBox(0,"","Restarting")
    GUIDelete($GUI_Main)
    CGGui()
EndFunc

Specifically what happens is that if I leave all input blank on the GUI then I get the first msgbox telling me that the logfile directory does not exist, then a msgbox telling me that I am restarting (there as a temporary debug), then a msgbox telling me "results file not specified", then the restart msgbox again and so on and then the script of course fails to execute since the input was invalid to begin with.

In other words, instead of going back the the CGGui() function as specified in the Restart() function, my script just picks up where it left off in the Go() function. What am I doing wrong?

Thanks!

Posted (edited)

Not enough information. Somewhere inside CGGui() you must be calling Go(). Would need to see the contents of that function to point it out.

<{POST_SNAPBACK}>

Contents of the CGGui() function...

Func CGGui()

Opt("GUIOnEventMode",1)
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$GUI_Main=GuiCreate("OWA/IIS Log Parser", 481, 142,(@DesktopWidth-481)/2, (@DesktopHeight-142)/2)

$Label_1 = GuiCtrlCreateLabel("Exchange Server IP:", 10, 70, 100, 20)
$Label_2 = GuiCtrlCreateLabel("Logs Directory:", 10, 10, 100, 20)
$Label_3 = GuiCtrlCreateLabel("Results File:", 10, 40, 100, 20)
$Input_ExchIP = GuiCtrlCreateInput("172.16.4.46", 130, 70, 120, 20)
$Input_logdir = GuiCtrlCreateInput("", 130, 10, 250, 20)
$Input_results = GuiCtrlCreateInput("", 130, 40, 250, 20)
$Button_LogBrowse = GuiCtrlCreateButton("Browse...", 390, 10, 80, 20)
$Button_ResultBrowse = GuiCtrlCreateButton("Browse...", 390, 40, 80, 20)
$Button_GO = GuiCtrlCreateButton("GO!", 10, 100, 460, 30)
$Checkbox_CustomFilter = GuiCtrlCreateCheckbox("Custom Filter:", 260, 70, 85, 20)
$Input_CustomFilter = GuiCtrlCreateInput("", 350, 70, 120, 20)

GUICtrlSetState($Input_CustomFilter, $GUI_HIDE)
GUICtrlSetOnEvent($Button_LogBrowse,"Browse4Logs")
GUICtrlSetOnEvent($Button_ResultBrowse,"Browse4Results")
GUICtrlSetOnEvent($Checkbox_CustomFilter,"CustomFilterCreate")
GUICtrlSetOnEvent($Button_GO,"Go")
GUISetOnEvent($GUI_EVENT_CLOSE,"CGTerm")
GUISetState(@SW_SHOW)
EndFunc
Edited by sublimnl

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
  • Recently Browsing   0 members

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