msalperen Posted October 6, 2010 Share Posted October 6, 2010 Hi, I'm trying to update an edit box due to the value returned by a checkbox. I'm using On event mode Func btnOpenForm6_click() $SwiftKodu = GUICtrlRead($Combo401) $Header= StringFormat("some variable here", $SwiftKodu) $sonuc = StringFormat("%s", $Header) & $Deneme $sonuc2 = StringFormat(" Basic Header ") if BitAnd(GUICtrlRead($Checkbox1), $GUI_CHECKED) == $GUI_CHECKED Then GUICtrlSetData($Edit1, $sonuc) Else GUICtrlSetData($Edit1, $sonuc2) Endif EndFunc As far as what I've read from the forum, this should do the trick but it always turns $sonuc2 whether the checkbox is ticked or not. I have tried to include it in a while wend loop but no success. I appreciate any help on my issue. Kindly Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 6, 2010 Share Posted October 6, 2010 It's something about how you handle your strings, because this works fine: #include <GuiConstantsEx.au3> Opt("GuiOnEventMode", 1) Global $hGUI, $Edit1, $Checkbox1 $hGUI = GUICreate("Test", 300, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $Edit1 = GUICtrlCreateEdit("", 20, 20, 260, 20) $Checkbox1 = GUICtrlCreateCheckbox("Test Me!", 20, 60, 260, 20) GUICtrlSetOnEvent(-1, "btnOpenForm6_click") GUISetState() While 1 Sleep(10) WEnd Func _Quit() Exit EndFunc ;==>_Quit Func btnOpenForm6_click() Local $sonuc = "Checked!" Local $sonuc1 = "Unchecked!" If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) == $GUI_CHECKED Then GUICtrlSetData($Edit1, $sonuc) Else GUICtrlSetData($Edit1, $sonuc1) EndIf EndFunc ;==>btnOpenForm6_click Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
msalperen Posted October 6, 2010 Author Share Posted October 6, 2010 It's something about how you handle your strings, because this works fine: #include <GuiConstantsEx.au3> Opt("GuiOnEventMode", 1) Global $hGUI, $Edit1, $Checkbox1 $hGUI = GUICreate("Test", 300, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $Edit1 = GUICtrlCreateEdit("", 20, 20, 260, 20) $Checkbox1 = GUICtrlCreateCheckbox("Test Me!", 20, 60, 260, 20) GUICtrlSetOnEvent(-1, "btnOpenForm6_click") GUISetState() While 1 Sleep(10) WEnd Func _Quit() Exit EndFunc ;==>_Quit Func btnOpenForm6_click() Local $sonuc = "Checked!" Local $sonuc1 = "Unchecked!" If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) == $GUI_CHECKED Then GUICtrlSetData($Edit1, $sonuc) Else GUICtrlSetData($Edit1, $sonuc1) EndIf EndFunc ;==>btnOpenForm6_click There's something certainly I'm missing but I can not find it. Your example turns "Unchecked!" in both condition within my code. And also the following one which uses combobox control works well! $Combo401 = GUICtrlCreateCombo("ASTRFKM", 392, 80, 137, 25) GUICtrlSetData(-1, "BKCHCNBJ|ABNATRIS|ISBKTRIS|") ... Gui details here ... Func btnOpenForm6_click() $DummyVariable = GUICtrlRead($Combo401) $Header= StringFormat(" some text %s ", $DummyVariable) $Deneme = StringFormat(" some text here also") $sonuc = StringFormat("%s", $Header) & $Deneme GUICtrlSetData($Edit1, $sonuc) EndFunc Link to comment Share on other sites More sharing options...
trung0407 Posted October 6, 2010 Share Posted October 6, 2010 (edited) you must be doing something wrong with the strings. Simply take PsaltyDS's code and replace it with yours and seriously, there is no need to use StringFormat, it will complicate your code Edited October 6, 2010 by trung0407 Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 6, 2010 Share Posted October 6, 2010 There's something certainly I'm missing but I can not find it. Your example turns "Unchecked!" in both condition within my code.You have yet to provide a short, runnable, reproducer script that shows your symptoms. When you run my unmodified demo, does it work? I'll bet it does.Now you post a short, complete, runnable script that demonstrates your issue. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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