Myicq Posted October 28, 2010 Share Posted October 28, 2010 I am trying to develop an application where the user is presented with a popup screen (second gui) to enter numeric values in different input boxes. At the moment I open the input form using opensubform($BatchNumberValue, "BATCH") and in the form I run an if loop depending on the word as parameter 2. My problem is that I do not know how to pass an input control as ByRef parameter, so that the function called can read from and write to the input control, depending on the reference. In pseudokode: ;first field opensubform($BatchNumberValue) ;second field opensubform($TestNumber) ;my input function func opensubform(ByRef $inputcontrol) ;... create local GUI code here ;... ;enter current value GuiCtrlSetData($myLocalInput, GuiCtrlRead($inputcontrol)) ; << this part works endfunc However the WRITING of the value back to the inputfield does not work. Has anyone made an example of using input controls with a popup for data entry ? Preferably with the popup opening when the input field on main form receives focus (however this has other drawbacks, since it won't give away the focus again... ) Will be happy to post complete code once all works. I am using events programming. Thanks! I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
martin Posted October 30, 2010 Share Posted October 30, 2010 (edited) If you pass the variable for the input then you must not send it as ByRef because if the function changes its value then you will loose the reference to that control and you will not be able to interact with it any more. You could use GuiCtrlSetData in the function, or have the function return the data and use the return from the function as a way of deciding what to put in the input? You could also set the values of @error and @extended in the function to flag different things such as OK, Aborted, invalid data etc. Edited October 30, 2010 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Myicq Posted October 30, 2010 Author Share Posted October 30, 2010 You could use GuiCtrlSetData in the function, or have the function return the data and use the return from the function as a way of deciding what to put in the input? You could also set the values of @error and @extended in the function to flag different things such as OK, Aborted, invalid data etc. So you mean I can do something like either function getinput($myfield) ; gui stuff here guictrlsetdata($myfield, result) endfunc (will AutoIT know which field it is.. ? I imagine only the CONTENT of the field will be passed in $myfield ?) OR as in method two: $temp = getinput(guictrlread($batchnumberfield)) if @error = 0 then guictrlsetdata($batchnumberfield, $temp) endif I will experiment a bit with your hints. If you have more to add, feel free Thanks for your help. I am just a hobby programmer, and nothing great to publish right now. 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