butterfly Posted January 29, 2014 Share Posted January 29, 2014 This is my first post on this forum because I was trying to stay as far away as possible from here for a long time because I was afraid I would get shot down anyway I have no prior experience in any programming language but now I am truly stuck, although it might be very simple I am making a interface with over 200 checkboxes and some of the checkboxes are being grouped as in click checkbox "Q" to check/uncheck boxes Q1 to Q15 for click checkbox "R" to check/uncheck boxes R1 to R31 for for example (notice diffrence in the amount being possible stored in $array Case $MagicCoreCtsa Dim $MagicCoreCtsa_array[9] = [$M14,$M13,$M12,$M11,$M10,$10E,$9ED,$8ED,$7E] MultipleSetSelect() Func MultipleSetSelect() If GUICtrlRead($MagicCoreCtsa) = $GUI_CHECKED Then For $Z = 0 to (UBound($MagicCoreCtsa_array) -1) GUICtrlSetState($MagicCoreCtsa_array[$Z], $GUI_CHECKED) Next Else For $Z = 0 to (UBound($MagicCoreCtsa_array) -1) GUICtrlSetState($MagicCoreCtsa_array[$Z], $GUI_UNCHECKED) Next EndIf EndFunc This code Above is currently working as intended, I created it myself but I believe there must be a smarter way of managing Because this proces needs to be repeated about 30+ times and I want my code as short as possible I am trying to following here under I am trying to explain what I intend to do, is it possible and how to proper code it? local = "$MagicCoreCtsa" ;Does not work how I want Case $troll ;this is replaced by $troll but should represent "$MagicCoreCtsa" so my function can process it local $troll2 =;$ClassicCtsa_array Dim $troll2[9] = [$M14,$M13,$M12,$M11,$M10,$10E,$9ED,$8ED,$7E] $troll2 MultipleSetSelect() local $troll = $MagicModernCtsa" Case $troll ;;this is replaced by $troll but should represent "$MagicModernCtsa"" so my function can process it local $troll2 ="$MagicModernCtsa $troll2[22] = [$MI,$VI,$WL,$TE,$ST,$EX,$UZ,$UL,$UD,$MM,$NE,$PR,$IN,$PS,$AP,$OD,$TOR,$JUD,$ONS,$LGN,$SCG,$7E] ;repeat steps above etc;etc etc 15 more Times EndSwitch Func MultipleSetSelect() If GUICtrlRead($troll) = $GUI_CHECKED Then For $Z = 0 to (UBound($troll2) -1) GUICtrlSetState($troll2[$Z], $GUI_CHECKED) Next Else For $Z = 0 to (UBound($troll2) -1) GUICtrlSetState($troll2[$Z], $GUI_UNCHECKED) Next EndIf EndFunc I hope this is clear enough for everyone to understand here. Link to comment Share on other sites More sharing options...
butterfly Posted January 30, 2014 Author Share Posted January 30, 2014 Well well Well, I have fixed what I wanted but and works as intended but I was wondering how I could optimize my code (what is the best practice and cleanest way of writing it) I would really appreciate that Case $ModernCtsa $troll = $ModernCtsa Dim $ModernCtsa_array[5]=[$1,$2,$3,$4,$5] $troll2 = $ModernCtsa_array MultipleSetSelect() Case $ExtendedCtsa $troll = $ExtendedCtsa Dim $ExtendedCtsa_array[8]=[$1,$2,$3,$4,$5,$6,$7,$8] $troll2 = $ExtendedCtsa_array MultipleSetSelect() Func MultipleSetSelect() If GUICtrlRead($troll) = $GUI_CHECKED Then For $Z = 0 to (UBound($troll2) -1) GUICtrlSetState($troll2[$Z], $GUI_CHECKED) Next Else For $Z = 0 to (UBound($troll2) -1) GUICtrlSetState($troll2[$Z], $GUI_UNCHECKED) Next EndIf EndFunc Is it there a smarter way of using my $troll variables then I am currently doing, I have to remind you that I have no basic knowlegde of programming but I am trying my best Regards Rene 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