Champak Posted March 3, 2008 Share Posted March 3, 2008 (edited) Based on the key I press, the text is sent to my editor, but the letter is not being carried out in the function in the "GUICtrlSetBkColor" portion. I would think that the letter would be inserted there and then the color would be set at $OSK_MA and $OSK_MQ, but that is not happening, although the actual letter is being passed to the editor. Why is this happening? Note, this is also preventing me from putting the $OSK_Input'1' through '3' in a loop, which I was willing to live with, until I ran into this problem with the setting of the color. Case $meg = $button _KeyboardSetText("M");The function call Func _KeyboardSetText($fData) GUICtrlSetBkColor("$OSK_" & $fData & "A", $OSKKPress);<==Not working GUICtrlSetBkColor("$OSK_" & $fData & "Q", $OSKKPress);<==Not working KeyboardType() GUICtrlSetData($OSK_Input1, GUICtrlRead($OSK_Input1) & $fData);<==Working GUICtrlSetData($OSK_Input2, GUICtrlRead($OSK_Input2) & $fData);<==Working GUICtrlSetData($OSK_Input3, GUICtrlRead($OSK_Input3) & $fData);<==Working GUICtrlSetBkColor("$OSK_" & $fData & "A", $RoadC);<==Not working GUICtrlSetBkColor("$OSK_" & $fData & "Q", $RoadC);<==Not working EndFuncoÝ÷ ØÈÁ«-¢¶ºÚ"µÍ][ÝÉÌÍÓÔÒ×É][ÝÈ [È ÌÍÙ]H [È ][ÝÐI][Ý in a mesbox, I see it as I should -- "$OSK_MA" --, but it just doesn't work. Edited March 3, 2008 by Champak Link to comment Share on other sites More sharing options...
weaponx Posted March 3, 2008 Share Posted March 3, 2008 (edited) Variables in quotes are not executed like in php. You need to use Eval() to do this. Case $meg = $button _KeyboardSetText("M");The function call Func _KeyboardSetText($fData) GUICtrlSetBkColor(Eval("OSK_" & $fData & "A"), $OSKKPress);<==Not working GUICtrlSetBkColor(Eval("OSK_" & $fData & "Q"), $OSKKPress);<==Not working KeyboardType() GUICtrlSetData($OSK_Input1, GUICtrlRead($OSK_Input1) & $fData);<==Working GUICtrlSetData($OSK_Input2, GUICtrlRead($OSK_Input2) & $fData);<==Working GUICtrlSetData($OSK_Input3, GUICtrlRead($OSK_Input3) & $fData);<==Working GUICtrlSetBkColor(Eval("OSK_" & $fData & "A"), $RoadC);<==Not working GUICtrlSetBkColor(Eval("OSK_" & $fData & "Q"), $RoadC);<==Not working EndFunc EDIT: Removed dollar signs from Eval() Edited March 3, 2008 by weaponx Link to comment Share on other sites More sharing options...
Champak Posted March 3, 2008 Author Share Posted March 3, 2008 (edited) I kind of get it....but I don't get it . I took all the variables out of quotes, but is still isn't working, I also changed it around a little and put the loop in it, and now the letter wont set...and there are no variables in quotes there. Func _KeyboardSetText($fData) $OSK0_ = "$OSK_" $OSK1_ = Eval("OSK0_") $Letter = Eval("fData") GUICtrlSetBkColor($OSK1_ & $Letter & "A", $OSKKPress) GUICtrlSetBkColor($OSK1_ & $Letter & "Q", $OSKKPress) SoundPlay($IGN & "\Keys.mp3") KeyboardType() For $i = 1 To 3 GUICtrlSetData($OSK_Input & $i, GUICtrlRead($OSK_Input & $i) & $Letter) Next GUICtrlSetBkColor($OSK1_ & $Letter & "A", $RoadC) GUICtrlSetBkColor($OSK1_ & $Letter & "Q", $RoadC) EndFunc Edited March 3, 2008 by Champak Link to comment Share on other sites More sharing options...
martin Posted March 3, 2008 Share Posted March 3, 2008 I kind of get it....but I don't get it . I took all the variables out of quotes, but is still isn't working, I also changed it around a little and put the loop in it, and now the letter wont set...and there are no variables in quotes there. Func _KeyboardSetText($fData) $OSK0_ = "$OSK_" $OSK1_ = Eval("OSK0_") $Letter = Eval("fData") GUICtrlSetBkColor($OSK1_ & $Letter & "A", $OSKKPress) GUICtrlSetBkColor($OSK1_ & $Letter & "Q", $OSKKPress) SoundPlay($IGN & "\Keys.mp3") KeyboardType() For $i = 1 To 3 GUICtrlSetData($OSK_Input & $i, GUICtrlRead($OSK_Input & $i) & $Letter) Next GUICtrlSetBkColor($OSK1_ & $Letter & "A", $RoadC) GUICtrlSetBkColor($OSK1_ & $Letter & "Q", $RoadC) EndFunc You're not doing what weaponex showed you. Eval("fData")& $Letter & "A" is not the same as Eval("fData" & $Letter & "A" ) 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...
weaponx Posted March 3, 2008 Share Posted March 3, 2008 Here is a simpler example: $varA = "SUCCESS" MsgBox(0,"", Eval("var" & "A")) Link to comment Share on other sites More sharing options...
Champak Posted March 3, 2008 Author Share Posted March 3, 2008 (edited) Oh, I didn't notice that he actually put a code in, I thought he just quoted me, however, that still doesn't give me anything different from what I already have. I copied it exactly and it still isn't setting the color to the element. Edited March 3, 2008 by Champak Link to comment Share on other sites More sharing options...
martin Posted March 3, 2008 Share Posted March 3, 2008 Oh, I didn't notice that he actually put a code in, I thought he just quoted me, however, that still doesn't give me anything different from what I already have. I copied it exactly and it still isn't setting the color to the element.You need to show more code then I think. 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...
Champak Posted March 3, 2008 Author Share Posted March 3, 2008 (edited) Thanks to both, it turns out I had something else in the script affecting it, so that is fixed now. But why can't I get the loop portion to work? There isn't any variables in quotes for the Eval() to take care of like my initial problem. Unless the logic of it is messed up. "OSK_Input" is not an actual element, I have that set as a Global. Now "OSK_Input1", "OSK_Input2", and "OSK_Input3" are the actual textbox elements. Now the loop cycles through and adds 1, 2, 3 on the end of the global call and hence sets the letter to all of those inputs. Is this flawed? GUICtrlSetBkColor(Eval("OSK_" & $fData & "A"), $OSKKPress) GUICtrlSetBkColor(Eval("OSK_" & $fData & "Q"), $OSKKPress) KeyboardType() For $i = 1 To 3 GUICtrlSetData($OSK_Input & $i, GUICtrlRead($OSK_Input & $i) & $fData);<==Not working Next GUICtrlSetBkColor(Eval("OSK_" & $fData & "A"), $RoadC) GUICtrlSetBkColor(Eval("OSK_" & $fData & "Q"), $RoadC) Not that important...just want to understand why it isn't working. Edited March 3, 2008 by Champak Link to comment Share on other sites More sharing options...
weaponx Posted March 3, 2008 Share Posted March 3, 2008 You can't do this either:GUICtrlSetData($OSK_Input & $i, GUICtrlRead($OSK_Input & $i) & $fData);<==Not workingYou are trying to do things the language just doesn't support.Instead:GUICtrlSetData(Eval("OSK_Input" & $i), GUICtrlRead(Eval("OSK_Input" & $i)) & $fData);<==Not workingThis is why with AutoIt you are better off putting all of your controls into an array so they can be accessed by index.Example:Dim $inputArray[3]$inputArray[0] = GUICtrlCreateInput("Example 1", 10, 10)$inputArray[1] = GUICtrlCreateInput("Example 2", 10, 30)$inputArray[2] = GUICtrlCreateInput("Example 3", 10, 50)For $X = 0 to Ubound($inputArray) - 1 ConsoleWrite(GUICtrlRead($inputArray[$X]) & @CRLF)Next Link to comment Share on other sites More sharing options...
Champak Posted March 3, 2008 Author Share Posted March 3, 2008 Unbelievable, you know I actually tried the following:GUICtrlSetData(Eval($OSK_Input & $i), GUICtrlRead($OSK_Input & $i)) & $fData).I just missed the "$" sign on the "OSK_Input".But I thought that it would be OK, since the "$OSK_Input" wasn't a variable of something in a quote as you said:"Variables in quotes are not executed....."But I understand the basics of it now, thanks.....however, why does the "$i" get away with having the dollar sign.P.S. I was actually thinking of GUI elements in arrays at one time, I'll look into it again. Link to comment Share on other sites More sharing options...
weaponx Posted March 3, 2008 Share Posted March 3, 2008 (edited) Unbelievable, you know I actually tried the following:GUICtrlSetData(Eval($OSK_Input & $i), GUICtrlRead($OSK_Input & $i)) & $fData).I just missed the "{:content:}quot; sign on the "OSK_Input".But I thought that it would be OK, since the "$OSK_Input" wasn't a variable of something in a quote as you said:"Variables in quotes are not executed....."But I understand the basics of it now, thanks.....however, why does the "$i" get away with having the dollar sign.P.S. I was actually thinking of GUI elements in arrays at one time, I'll look into it again.$var1 = 'A'$var2 = 'B'$var3 = 'C'For $i = 1 to 3ConsoleWrite(Eval("var" & $i))NextThis code relies upon the variables $var1, $var2, $var3 already existing. Without Eval() you will see "var1var2var3" output to the console (or an error if you use $var & $i). Eval() "renders" whatever string you pass to it into the variable with the same name. Edited March 3, 2008 by weaponx Link to comment Share on other sites More sharing options...
Champak Posted March 3, 2008 Author Share Posted March 3, 2008 Got you, thanks. 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