Morthawt Posted September 9, 2011 Share Posted September 9, 2011 Is it possible to have a function that accepts an input from the user and use that input to output its results to? I mean for example: Func Test($input) Then that $input (containing the name of the variable we want to use in the program) be translated some how so it can be used as a variable in that function? So I could output the results from that function to $ohyeah or $bang or what ever I typed into an input box to be sent into there under the $input of the function? Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 9, 2011 Moderators Share Posted September 9, 2011 Morthawt, I am somewhat bemused as exactly what you have asked in your question, but I think this shows how to do it: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 200, 20) $hButton = GUICtrlCreateButton("Do It!", 10, 50, 80, 30) $hLabel = GUICtrlCreateLabel("", 10, 100, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton ; Call function with content of input $iLength = _Function(GUICtrlRead($hInput)) ; Use the returned value to refill the input GUICtrlSetData($hInput, $iLength) EndSwitch WEnd Func _Function($sString) ; A simple function Return StringLen($sString) EndFunc If not, please explain more clearly what it is you want. 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 Link to comment Share on other sites More sharing options...
UEZ Posted September 9, 2011 Share Posted September 9, 2011 (edited) You mean something like that? $input = InputBox("Test", "Enter something", "", "", "", 130) Assign($input & "$", "Test", 1) ;this will create a variable with the name you entered and assign test to it MsgBox(0, "Test", Eval($input & "$")) Br, UEZ Edited September 9, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Morthawt Posted September 9, 2011 Author Share Posted September 9, 2011 Morthawt, I am somewhat bemused as exactly what you have asked in your question, but I think this shows how to do it: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 200, 20) $hButton = GUICtrlCreateButton("Do It!", 10, 50, 80, 30) $hLabel = GUICtrlCreateLabel("", 10, 100, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton ; Call function with content of input $iLength = _Function(GUICtrlRead($hInput)) ; Use the returned value to refill the input GUICtrlSetData($hInput, $iLength) EndSwitch WEnd Func _Function($sString) ; A simple function Return StringLen($sString) EndFunc If not, please explain more clearly what it is you want. M23 Err yea I don't think thats it. Here is an example. I make a function called ObtainInput($data) well I want to be able to call that function with something like ObtainInput('password') and the output it ends up with will be sent to $password or call the function like this ObtainInput('personsname') and it will output their name they typed into the input box to the $personsname variable. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Morthawt Posted September 9, 2011 Author Share Posted September 9, 2011 You mean something like that? $input = InputBox("Test", "Enter something", "", "", "", 130) Assign($input & "$", "Test", 1) ;this will create a variable with the name you entered and assign test to it MsgBox(0, "Test", Eval($input & "$")) Br, UEZ I just tested this but it seems to not make a variable with the name. I added at the top of your code Global $ding and then added another message box at the end displaying $ding. Then I typed ding into the box and your box came up with test but my box was empty. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
javip Posted September 9, 2011 Share Posted September 9, 2011 you mean something like: $password= (GUICtrlRead($Input1)) this assigns whatever is in the input box to the $password variable. might not be that simple though. Link to comment Share on other sites More sharing options...
Morthawt Posted September 9, 2011 Author Share Posted September 9, 2011 you mean something like: $password= (GUICtrlRead($Input1)) this assigns whatever is in the input box to the $password variable. might not be that simple though. That code will just assign the value from a GUI input box to a preset $password variable. What I am talking about is having the "$password" variable NAME set by what ever is typed in the input box so if I type in "chicken" then the next input I type will go into a $chicken variable. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
smartee Posted September 9, 2011 Share Posted September 9, 2011 hello Morthawt, Assign is indeed the function you're looking for, try this demo:$sVarName = InputBox("", "Enter variable name:") Assign($sVarName, InputBox("", "Enter value:")) MsgBox(64, "", "Content of $" & $sVarName & " is " & Eval($sVarName)) Hope this helps Link to comment Share on other sites More sharing options...
Rogue5099 Posted September 9, 2011 Share Posted September 9, 2011 hello Morthawt, Assign is indeed the function you're looking for, try this demo:$sVarName = InputBox("", "Enter variable name:") Assign($sVarName, InputBox("", "Enter value:")) MsgBox(64, "", "Content of $" & $sVarName & " is " & Eval($sVarName)) Hope this helps Entered Glass in first Input and Beer in second. Output = Content of $Glass is Beer I'm thursty now! My projects: Inventory / Mp3 Inventory, Computer Stats 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