Sign in to follow this  
Followers 0
Myicq

Input control as parameter

3 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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.

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