ojef1 Posted March 1, 2011 Posted March 1, 2011 I'm trying to make a GUI that accepts 3 values: row, lastRow, and delay and I'm having all kinds of problems with it. I want to have 3 integer values stored in each variable ($row, $lastRow, and $delay), which is why I use the Number() function. Eventually, I want to put in tests to verify the inputs are valid integers and the range is valid, etc. But for now I'd just like to get it working. Right now the msgbox i put in indicates each variable equals nothing ... It says "first row is (blank) @CRLF last row is (blank) @CRLF delay is (blank)" expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIButton.au3> #include <GUIToolbar.au3> input() Func input() GUICreate("Emax", 380, 180, @DesktopWidth / 4 - 160, @DesktopHeight / 4 - 45, -1, 0x00000018) GUICtrlCreateLabel("Enter the row to start with: ", 10, 5) $input1 = GUICtrlCreateInput("", 10, 25, 100, 20) $row = GUICtrlRead($input1, 1) Number($row) GUICtrlCreateLabel("Enter the last row: ", 10, 50) $input2 = GUICtrlCreateInput("", 10, 65, 100, 20) $lastRow = GUICtrlRead($input2, 1) GUICtrlCreateLabel("Enter a time delay (in milliseconds) in case the network is running slow: ", 10, 90, 350, 20) $input3 = GUICtrlCreateInput("", 10, 105, 100, 20) ;slows whole program down $delay = GUICtrlRead($input3, 1) Number($delay) $enterBtn = GUICtrlCreateButton("Enter", 20, 145, 60, 20) $cancelBtn = GUICtrlCreateButton("Cancel", 100, 145, 60, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit ElseIf $msg = $enterBtn Then MsgBox(0, "??", "first row is " & $row & @CRLF & "last row is " & $lastRow & @CRLF & "delay is " & $delay) input() ;range($row, $lastRow) ElseIf $msg = $cancelBtn Then Exit EndIf WEnd EndFunc
Moderators Melba23 Posted March 1, 2011 Moderators Posted March 1, 2011 (edited) ojef1,You are reading the inputs as soon as they are created - so unsuprisingly they are blank. You need to read them when the button is pushed - like thisexpandcollapse popup#include <GUIConstantsEx.au3> #include <GUIButton.au3> #include <GUIToolbar.au3> input() Func input() GUICreate("Emax", 380, 180, @DesktopWidth / 4 - 160, @DesktopHeight / 4 - 45, -1, 0x00000018) GUICtrlCreateLabel("Enter the row to start with: ", 10, 5) $input1 = GUICtrlCreateInput("", 10, 25, 100, 20) GUICtrlCreateLabel("Enter the last row: ", 10, 50) $input2 = GUICtrlCreateInput("", 10, 65, 100, 20) GUICtrlCreateLabel("Enter a time delay (in milliseconds) in case the network is running slow: ", 10, 90, 350, 20) $input3 = GUICtrlCreateInput("", 10, 105, 100, 20) ;slows whole program down $enterBtn = GUICtrlCreateButton("Enter", 20, 145, 60, 20) $cancelBtn = GUICtrlCreateButton("Cancel", 100, 145, 60, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit ElseIf $msg = $enterBtn Then $row = Number(GUICtrlRead($input1, 1)) $lastRow = Number(GUICtrlRead($input2, 1)) $delay = Number(GUICtrlRead($input3, 1)) MsgBox(0, "??", "first row is " & $row & @CRLF & "last row is " & $lastRow & @CRLF & "delay is " & $delay) ElseIf $msg = $cancelBtn Then Exit EndIf WEnd EndFuncA couple of other points:- 1. You need to have a variable to receive the output of Number - as you were doing it, nothing would happen. - 2, You were recalling your function inside the function - this is known as recursion and would very quickly lead to a crash! Take a look at the Recursion tutorial in the Wiki to see why. All clear? Please ask if not. M23Edit: Wrong button too soon! Edited March 1, 2011 by Melba23 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
somdcomputerguy Posted March 1, 2011 Posted March 1, 2011 (edited) Move EndFunc to before the While 1.<br><br> Edited March 1, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Moderators Melba23 Posted March 1, 2011 Moderators Posted March 1, 2011 somdcomputerguy, Are you sure you are in the right thread? 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
AdmiralAlkex Posted March 1, 2011 Posted March 1, 2011 Number() gives a number, not a integer. You want Int() .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
somdcomputerguy Posted March 1, 2011 Posted March 1, 2011 somdcomputerguy,Are you sure you are in the right thread? M23Ya. I was trying to edit my post, then saw you already replied, then I realized my answer was wrong anyway.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
ojef1 Posted March 1, 2011 Author Posted March 1, 2011 ok thanks for all the help...i was going the wrong direction trying to figure it out myself and getting more confused....this is the second recursion problem I've ran into in this program, I think I might be developing a bad habit...is there any sort of branch function or something I could use instead if I wanted it to run back through the function (if the inputs were invalid for example)? The way I have it set up was just for testing purposes but I will probably need to do something similar (only with a way out). Thanks again
ojef1 Posted March 1, 2011 Author Posted March 1, 2011 Also do I need to declare my variables outside of the function if I'm going to use them outside of the function?
Moderators Melba23 Posted March 1, 2011 Moderators Posted March 1, 2011 ojef1,If you want to repeat something like that, use an infinite While...WEnd loop and then an ExitLoop when you want to break out of it.Do read the tutorial I linked to - if you do not know what you are doing, recursion will crash your system quicker than almost anything else. 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
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