tweaker Posted May 8, 2011 Share Posted May 8, 2011 (edited) I'm having a bit of difficulty with a gui login procedure for my app and I don't know why it isn't working.Opt('MustDeclareVars', 1) Login() Func Login() Local $username, $password, $ip, $btn, $msg GUICreate(" Login", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 145, -1, 0x00000018); WS_EX_ACCEPTFILES $username = GUICtrlCreateInput("Username", 10, 5, 300, 20) $password = GUICtrlCreateInput("Password", 10, 35, 300, 20) $ip = GUICtrlCreateInput("IP",10,65,300,20) $btn = GUICtrlCreateButton("Ok", 40, 95, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn ExitLoop EndSelect WEnd EndFunc ; Open database connection DataInit() OnAutoItExitRegister("DataExit") if not DataConnect(1,"" & $ip & "","" & $username & "","" & $password & "","MtgoData",0,14430) then Exit(MsgBox(16,"No database connection",DataError()))If I remove the gui login process and put the 3 values straight into the code it works perfectly.if not DataConnect(1,"192.168.100.52","useraccess","pwdabc123","db",0,14430) then Exit(MsgBox(16,"No database connection",DataError()))The error I'm getting:quote_collection.au3 (44) : ==> Variable used without being declared.:Does anyone have any suggestions on how to make it work properly? Edited May 8, 2011 by tweaker Link to comment Share on other sites More sharing options...
GEOSoft Posted May 8, 2011 Share Posted May 8, 2011 Not sure why that is the error message. It probably has something to do with some code you didn't show. There is however a potential problem in that you have declared $username, $password and $ip as local only which means they will not be valid outside the function login() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 8, 2011 Share Posted May 8, 2011 Also $username, $password and $ip is just ControlId's to the respective controls. If you want the text they contains use GUICtrlRead() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
pieeater Posted May 8, 2011 Share Posted May 8, 2011 (edited) if it helps you can use the login udf i made as a reference, however i used my login with ini files, not databases :/ links in my signiture Edited May 8, 2011 by pieeater [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
tweaker Posted May 12, 2011 Author Share Posted May 12, 2011 Also $username, $password and $ip is just ControlId's to the respective controls. If you want the text they contains use GUICtrlRead()OK I changed the Local to Global as suggested above and added the GUICrtlRead() and so far its working great. Thanks for the suggestions!! Link to comment Share on other sites More sharing options...
GEOSoft Posted May 12, 2011 Share Posted May 12, 2011 Glad to hear it worked out. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now