cheeseandcereal Posted January 24, 2012 Posted January 24, 2012 (edited) So I have this gui set up and whenever i run the function for this button: Func Button1() $copy1 = FileCopy ( "C:UsersAdamDocumentsAdam's file'sMinecraft LauncherMinecraft Versionsminecraft 1.0.0 modsminecraft.jar", "C:UsersAdamAppDataRoaming.minecraftbin", 1 ) If $copy1 = 1 Then MsgBox ( 0, "Success", "The version transfer was a success" ) If $copy1 = 0 Then $fail1 = MsgBox ( 4+48, "Failure", "The version transfer was a failure would you like to try again?" ) If $fail1 = 6 Then Button1() EndFunc I get this error: C:UsersAdamDocumentsAdam's file'sMinecraft LauncherMinecraft Launcher2.au3 (48) : ==> Variable used without being declared.: If $fail1 = 6 Then Button1() If ^ ERROR What's wrong with this? If needed, my entire current script is here: expandcollapse popup#include <INet.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $YourIP = _GetIP()#Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Minecraft Launcher", 372, 242, 192, 123) GUISetBkColor(0x00FFFF) $Checkbox1 = GUICtrlCreateCheckbox("Default Minecraft", 8, 8, 153, 17) $Checkbox2 = GUICtrlCreateCheckbox("Minecraft Cracked", 8, 40, 161, 17) $Checkbox3 = GUICtrlCreateCheckbox("Private Server", 8, 72, 137, 17) $Checkbox4 = GUICtrlCreateCheckbox("Main Server", 8, 104, 153, 17) $Input1 = GUICtrlCreateInput("Input1", 8, 200, 193, 21) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetTip(-1, "IP Address") $Label1 = GUICtrlCreateLabel("IP Address", 72, 176, 55, 17) $Button2 = GUICtrlCreateButton("Go", 144, 80, 49, 25) $Button3 = GUICtrlCreateButton("Get IP", 208, 200, 57, 25) $Button1 = GUICtrlCreateButton("1.0.0 Mods", 232, 8, 121, 33) $Button4 = GUICtrlCreateButton("1.1.0", 232, 56, 121, 33) $Button5 = GUICtrlCreateButton("1.0.0 No Mods", 232, 104, 121, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch IF $nMsg = $Button1 Then Button1() If $nMsg = $Button2 Then Button2() If $nMsg = $Button3 Then Button3() If $nMsg = $Button4 Then Button4() If $nMsg = $Button5 Then Button5() WEndFunc Button1() $copy1 = FileCopy ( "C:UsersAdamDocumentsAdam's file'sMinecraft LauncherMinecraft Versionsminecraft 1.0.0 modsminecraft.jar", "C:UsersAdamAppDataRoaming.minecraftbin", 1 ) If $copy1 = 1 Then MsgBox ( 0, "Success", "The version transfer was a success" ) If $copy1 = 0 Then $fail1 = MsgBox ( 4+48, "Failure", "The version transfer was a failure would you like to try again?" ) If $fail1 = 6 Then Button1() EndFunc Func Button2() EndFunc Func Button3() GUICtrlSetData( $Input1, $YourIP ) EndFunc Func Button4() EndFunc Func Button5() EndFunc Edited January 24, 2012 by cheeseandcereal
Syed23 Posted January 24, 2012 Posted January 24, 2012 it says the variable is used without declaring just Declare variable as Global $fail1 after adding all the include files this will resolve your problem...To avoid these kind of issues in future add the below line in your code..[autoit]Opt(MustDeclareVars,1)[/autoit]all clear? Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
JohnOne Posted January 24, 2012 Posted January 24, 2012 The clue is in the error message. You make a conditional statement to set a non existent variable ($fail1) to 6 You might get away with it if $copy1 always = 0 (but you would not need an If condition then would you. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
cheeseandcereal Posted January 24, 2012 Author Posted January 24, 2012 (edited) . Edited January 24, 2012 by cheeseandcereal
cheeseandcereal Posted January 24, 2012 Author Posted January 24, 2012 (edited) it says the variable is used without declaring just Declare variable as Global $fail1 after adding all the include files this will resolve your problem... To avoid these kind of issues in future add the below line in your code.. [autoit] Opt(MustDeclareVars,1) [/autoit] all clear? Ok thanks. Im sorta new to this whole coding thing... obviously. That fixed my problem and I would gladly include that code in my script but when I do I get this error: C:UsersAdamDocumentsAdam's file'sMinecraft LauncherMinecraft Launcher.au3(9,20) : ERROR: syntax error Opt(MustDeclareVars, ~~~~~~~~~~~~~~~~~^ C:UsersAdamDocumentsAdam's file'sMinecraft LauncherMinecraft Launcher.au3 - 1 error(s), 0 warning(s) P.S. How do I delete posts on this forum? Edited January 24, 2012 by cheeseandcereal
cheeseandcereal Posted January 24, 2012 Author Posted January 24, 2012 Ok thanks. Im sorta new to this whole coding thing... obviously. That fixed my problem and I would gladly include that code in my script but when I do I get this error:C:UsersAdamDocumentsAdam's file'sMinecraft LauncherMinecraft Launcher.au3(9,20) : ERROR: syntax errorOpt(MustDeclareVars,~~~~~~~~~~~~~~~~~^C:UsersAdamDocumentsAdam's file'sMinecraft LauncherMinecraft Launcher.au3 - 1 error(s), 0 warning(s)P.S. How do I delete posts on this forum?Never mind, I just needed some quotation marks. Thanks for the help!
Syed23 Posted January 24, 2012 Posted January 24, 2012 Never mind, I just needed some quotation marks. Thanks for the help! Welcome! Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
Moderators Melba23 Posted January 24, 2012 Moderators Posted January 24, 2012 To all those who replied:$Checkbox1 = GUICtrlCreateCheckbox("Default Minecraft", 8, 8, 153, 17) $Checkbox2 = GUICtrlCreateCheckbox("Minecraft Cracked", 8, 40, 161, 17) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Please look at what you are helping to fix - this is not the sort of topic we want to encourage. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts