Remo1075 Posted February 19, 2010 Share Posted February 19, 2010 Hello, I'm having trouble trying to get the below code to add up the results of all IF statements as variables and if they = 0 (no boxes selected) then to ask in a msgbox, are you sure you want to proceed as you have not selected any boxes. Thanks for any help. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start If GUICtrlRead($German) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 4, '<AddLanguage Id="de-de" />', 1) If GUICtrlRead($French) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 5, '<AddLanguage Id="fr-fr" />', 1) If GUICtrlRead($Italian) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 6, '<AddLanguage Id="IT-IT" />', 1) If GUICtrlRead($Spanish) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 7, '<AddLanguage Id="es-es" />', 1) If GUICtrlRead($Dutch) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 8, '<AddLanguage Id="nl-nl" />', 1) If GUICtrlRead($Portuguese) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 9, '<AddLanguage Id="pt-pt" />', 1) If GUICtrlRead($Swedish) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 10, '<AddLanguage Id="sv-se" />', 1) If GUICtrlRead($Finnish) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 11, '<AddLanguage Id="fi-fi" />', 1) If GUICtrlRead($Czech) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 12, '<AddLanguage Id="cs-cz" />', 1) If GUICtrlRead($Russian) = $GUI_CHECKED Then _FileWriteToLine(@WindowsDir & "\Config.xml", 13, '<AddLanguage Id="ru-ru" />', 1) Exitloop EndSwitch WEnd Link to comment Share on other sites More sharing options...
whim Posted February 19, 2010 Share Posted February 19, 2010 (edited) This looks like one of those cases where arrays can both simplify and shorten the code, plus solve your is-anything-checked problem ... Can you show the checkbox creation code (or, if possible, the full source) ? whim Edited February 19, 2010 by whim Link to comment Share on other sites More sharing options...
martin Posted February 19, 2010 Share Posted February 19, 2010 (edited) EDIT: As whim pointed out afterwards, this is no help for checkboxes. One way While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start Select Case GUICtrlRead($German) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 4, '<AddLanguage Id="de-de" />', 1) Case GUICtrlRead($French) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 5, '<AddLanguage Id="fr-fr" />', 1) Case GUICtrlRead($Italian) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 6, '<AddLanguage Id="IT-IT" />', 1) Case GUICtrlRead($Spanish) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 7, '<AddLanguage Id="es-es" />', 1) Case GUICtrlRead($Dutch) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 8, '<AddLanguage Id="nl-nl" />', 1) Case GUICtrlRead($Portuguese) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 9, '<AddLanguage Id="pt-pt" />', 1) Case GUICtrlRead($Swedish) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 10, '<AddLanguage Id="sv-se" />', 1) Case GUICtrlRead($Finnish) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 11, '<AddLanguage Id="fi-fi" />', 1) Case GUICtrlRead($Czech) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 12, '<AddLanguage Id="cs-cz" />', 1) Case GUICtrlRead($Russian) = $GUI_CHECKED _FileWriteToLine(@WindowsDir & "\Config.xml", 13, '<AddLanguage Id="ru-ru" />', 1) Case Else MsgBox(262144, "ERROR", "No Selection made!") EndSelect ExitLoop EndSwitch WEnd Edited February 19, 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...
whim Posted February 19, 2010 Share Posted February 19, 2010 @martin that won't allow selecting multiple checkboxes though, will it ? i understood he meant checkboxes, not radio buttons whim Link to comment Share on other sites More sharing options...
Fire Posted February 19, 2010 Share Posted February 19, 2010 (edited) Remo10 I dont know is it that what you are looking for but try this way too may be it hols any idea for you. #include #include #include #include #include Global $avArray[6], $Checkbox[UBound($avArray)] #Region ### START Koda GUI section ### Form=Form1.kxf $Form1 = GUICreate(\"Form1\", 501, 307, 209, 125) $Checkbox[0] = GUICtrlCreateCheckbox(\"Checkbox1\", 296, 24, 137, 17) $Checkbox[1] = GUICtrlCreateCheckbox(\"Checkbox2\", 296, 64, 81, 17) $Checkbox[2] = GUICtrlCreateCheckbox(\"Checkbox3\", 296, 104, 97, 17) $Checkbox[3] = GUICtrlCreateCheckbox(\"Checkbox4\", 296, 144, 105, 17) $Checkbox[4] = GUICtrlCreateCheckbox(\"Checkbox5\", 296, 184, 113, 17) $Checkbox[5] = GUICtrlCreateCheckbox(\"Checkbox6\", 296, 216, 121, 17) $Button1 = GUICtrlCreateButton(\"Button1\", 56, 264, 97, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton(\"Button2\", 280, 264, 113, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 To UBound($avArray) - 1 If BitAND(GUICtrlRead($Checkbox[$i]),$GUI_UNCHECKED) Then $hanswer=MsgBox(65,\"Dou you wanna Proceed?\",\"Dou you want Proceed?\") confirm() Else MsgBox(64,\"DONE\",\"DONE\") EndIf Next EndSwitch WEnd func confirm() If $hanswer=\"1\" Then MsgBox(64,\"Done\",\"Done\") Exit Else MsgBox(64,\"Operation Cancelled!\",\"Operation Cancelled!\") Exit EndIf EndFunc Edited February 20, 2010 by Sh3llC043r [size="5"] [/size] Link to comment Share on other sites More sharing options...
martin Posted February 19, 2010 Share Posted February 19, 2010 @martinthat won't allow selecting multiple checkboxes though, will it ?i understood he meant checkboxes, not radio buttonswhimWhoops, you are correct, I was thinking radio buttons. 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...
Remo1075 Posted February 19, 2010 Author Share Posted February 19, 2010 Thanks guys for all the quick responses, one of the reasons why I love Autoit and the Autoit community. Sh3llC043r - Thanks alot just what I was looking for, I should be able to patch that in to my main script. 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