Sign in to follow this  
Followers 0
exodius

Guictrlread Issue

3 posts in this topic

I have this gui that thus far just checks to see if a file exists.. But even before getting that far, I just want to read the Input each time the "Fix" button is pressed so I can check again if the file doesn't exist. The problem I'm having is I can click "Fix" once and it works fine. If I press it again, the $filename = GUICtrlRead ($filename) line returns 0. Should I have that somewhere else?

#include <GUIConstants.au3>
GUICreate("Enter Filename to Fix", 451, 94, 296, 184)
GUICtrlCreateLabel("Enter the filename of the .csv file you converted.", 8, 8, 437, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$filename = GUICtrlCreateInput("filename.csv", 24, 48, 313, 28, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Fix = GUICtrlCreateButton("Fix", 360, 48, 75, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Fix
            FixFile()
    EndSelect
WEnd

Func FixFile()
$filename = GUICtrlRead ($filename) 
    If $filename <> "" Then
        If FileExists ( $filename ) Then 
            MsgBox ( 0, "", "Bingo" )
        Else
            MsgBox ( 0, "File not found!", "The file was not found. Make sure that the file """ & $filename & """ is in the same folder as this program." )
        EndIf
    Else
        MsgBox ( 0, "Enter filename", "You must enter a filename to fix before clicking the ""Fix"" button." )
    EndIf
EndFunc

Share this post


Link to post
Share on other sites



try this

#include <GUIConstants.au3>
global $filename
GUICreate("Enter Filename to Fix", 451, 94, 296, 184)
GUICtrlCreateLabel("Enter the filename of the .csv file you converted.", 8, 8, 437, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$filename = GUICtrlCreateInput("filename.csv", 24, 48, 313, 28, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Fix = GUICtrlCreateButton("Fix", 360, 48, 75, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Fix
            FixFile()
    EndSelect
WEnd

Func FixFile()

    If GUICtrlRead ($filename) <> "" Then
        If FileExists ( GUICtrlRead ($filename) ) Then
            MsgBox ( 0, "", "Bingo" )
        Else
            MsgBox ( 0, "File not found!", "The file was not found. Make sure that the file """ & GUICtrlRead ($filename) & """ is in the same folder as this program." )
        EndIf
    Else
        MsgBox ( 0, "Enter filename", "You must enter a filename to fix before clicking the ""Fix"" button." )
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

Awesome, I knew it would be some little fix like that, I just couldn't think of what it would be. Many thanks!

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  
Followers 0