Shark007 Posted April 5, 2022 Posted April 5, 2022 (edited) I have tried many things to make this For/Next loop work. It always fails with the ControlID's I assume it is going to fail when it reaches the final Function call too, but I haven't gotten that far yet. Any assistance you're able to offer would be appreciated. expandcollapse popupGlobal $Ini = @AppDataCommonDir & '\Test\settings.ini' Global $Check1 = GUICtrlCreateCheckbox("Check1", 20, 20, 100, 20) GUICtrlSetOnEvent(-1, 'Check1') Global $Check2 = GUICtrlCreateCheckbox("Check2", 50, 20, 100, 20) GUICtrlSetOnEvent(-1, 'Check2') Global $Check3 = GUICtrlCreateCheckbox("Check3", 80, 20, 100, 20) GUICtrlSetOnEvent(-1, 'Check3') Global $Check4 = GUICtrlCreateCheckbox("Check4", 110, 20, 100, 20) GUICtrlSetOnEvent(-1, 'Check4') Func Check1() If GUICtrlRead($Check1) = 1 Then IniWrite($Ini, 'Current', "Check1", '1') Else IniWrite($Ini, 'Current', "Check1", '4') EndIf EndFunc ;==>Check1 Func Check2() If GUICtrlRead($Check2) = 1 Then IniWrite($Ini, 'Current', "Check2", '1') Else IniWrite($Ini, 'Current', "Check2", '4') EndIf EndFunc ;==>Check2 Func Check3() If GUICtrlRead($Check3) = 1 Then IniWrite($Ini, 'Current', "Check3", '1') Else IniWrite($Ini, 'Current', "Check3", '4') EndIf EndFunc ;==>Check3 Func Check4() If GUICtrlRead($Check4) = 1 Then IniWrite($Ini, 'Current', "Check4", '1') Else IniWrite($Ini, 'Current', "Check4", '4') EndIf EndFunc ;==>Check4 ArrStore('check') Func ArrStore($strName) Local $arrNames[4] = ["Check1", "Check2", "Check3", "Check4"] If $strName = 'check' Then For $strName In $arrNames Local $var = _StringInsert($strName, '$', '1') If IniRead($Ini, 'Current', $strName, '4') = 4 Then GUICtrlSetState($var, 4) Else GUICtrlSetState($var, 1) EndIf $strName() Next EndIf EndFunc ;==>ArrStore Edited April 5, 2022 by Shark007
Developers Jos Posted April 5, 2022 Developers Posted April 5, 2022 It would help when you post something that is runnable! ... but I would use an Array for the Controlhandles and simplify/shorten the logic. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Solution jugador Posted April 5, 2022 Solution Posted April 5, 2022 (edited) @Shark007 for GUICtrlSetState to work in your example use Execute GUICtrlSetState(Execute($var), 4) #include <String.au3> Func Check1() ConsoleWrite('> Check1.....' & @CRLF) EndFunc ;==>Check1 Func Check2() ConsoleWrite('> Check2.....' & @CRLF) EndFunc ;==>Check2 Func Check3() ConsoleWrite('> Check3.....' & @CRLF) EndFunc ;==>Check3 Func Check4() ConsoleWrite('> Check4.....' & @CRLF) EndFunc ;==>Check4 ArrStore() Func ArrStore() Local $var Local $arrNames[4] = ["Check1", "Check2", "Check3", "Check4"] For $strName In $arrNames $var = _StringInsert($strName, '$', 0) ;~~ GUICtrlSetState(Execute($var), 4) ;~ <<<<= use Execute Execute($strName & '()') ;~ Method 1 ;Call($strName) ;~ Method 2 Next EndFunc ;==>ArrStore Edited April 5, 2022 by jugador Shark007 1
Shark007 Posted April 5, 2022 Author Posted April 5, 2022 (edited) 30 minutes ago, jugador said: @Shark007 for GUICtrlSetState to work in your example use Execute GUICtrlSetState(Execute($var), 4) Call($strName) Thank you. This is the solution that I seek. I appreciate your time. Edited April 5, 2022 by Shark007 jugador 1
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