PcExpert Posted February 8, 2009 Share Posted February 8, 2009 (edited) Hi all, Currently I have this code: CODE DELETED I'm currently editing the function 'editgroup_select'. this function should read all the values from the vakken.ini, and if the same value exists in the group-inifile, it should check the checkbox with the same name. This code however, doesnt work correctly. Could someone please point me in the right direction? The vakken.ini looks like this: [algemeen] vakken=vkTDM,vkDKP,vkDBT,vkVBS,vkCUT,vkFTW,vkPDC,vkKPN,vkPTT,vkHTF,vkKTM,vkPTC,vkWDD,vk,vk,vk,vk,vk, vk,vk,vk,vk,vk,vk,vk,vk,vk,vk,vk,vk, and a group file looka like this: [algemeen] vakken=vkTDM,vkDKP,vkDBT,vkPDC,vkKPN, Thanks! Edited February 9, 2009 by PcExpert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2009 Moderators Share Posted February 8, 2009 PcExpert,You need to set up 2 loops - the first gets the code of each profession in the group - the second checks which checkbox this value needs to tick:Func editgroup_select() If not FileExists("groepen\" & GUICtrlRead($newgroup) & ".ini") Or GUICtrlRead($newgroup) = "" Then MsgBox(64, "Cijfer Registratie Systeem | Melding", "Deze groep bestaat niet, of het invoerveld is leeg") Else $vakken = IniRead("groepen\" & GUICtrlRead($newgroup) & ".ini", "Algemeen", "Vakken", "") $vakken = StringReplace($vakken, "vk", "") $vakken_array = StringSplit($vakken, ",") $vakken1 = IniRead("vakken.ini", "Algemeen", "Vakken", "") $vakken1 = StringReplace($vakken1, "vk", "") $vakken_array1 = StringSplit($vakken1, ",") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $w = 1 To $vakken_array1[0] If $vakken_array1[$w] <> "" Then For $v = 1 To $vakken_array[0] If $vakken_array1[$w] = $vakken_array[$v] Then GUICtrlSetState($Checkbox[$w], $GUI_CHECKED) Next EndIf Next EndIf EndIf EndFuncThis works for me with your example .ini files.By the way, did you see my suggested change to those ugly loops here? I think not, or you would not have posted the code above!M23P.S. Please use tabs to indent your code- it makes it so much easier to read and post. Use "Tools - Tidy AutoIt Source" in SciTE - it does it all for you! Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PcExpert Posted February 8, 2009 Author Share Posted February 8, 2009 (edited) Thanks again:) I'm really beginning to think that your Crystal Ball is working... , because everytime I post a topic you are the one that answers, and very quick! My compliments for that:) Edited February 8, 2009 by PcExpert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2009 Moderators Share Posted February 8, 2009 (edited) PcExpert,I just like "vakken"s!Seriously, I now have a quite a good understanding of what your code is trying to do - and a fine collection of .ini files and "vakken" code! So it much easier for me to answer quickly than others.If you prefer, I could keep quiet next time ;-)M23 Edited February 8, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Spiff59 Posted February 8, 2009 Share Posted February 8, 2009 (edited) Speaking of loops... You could always replace: expandcollapse popupFor $i = 1 To 5 If StringLen($vakken_array[$i]) > 2 Then $CheckBox[$i] = GUICtrlCreateCheckbox("vk" & $i, 45, $top, 50, 20) $count += 1 $top += 20 EndIf Next $top = 50 For $i = 6 To 10 If StringLen($vakken_array[$i]) > 2 Then $CheckBox[$i] = GUICtrlCreateCheckbox("vk" & $i, 110, $top, 50, 20) $count += 1 $top += 20 EndIf Next $top = 50 For $i = 11 To 15 If StringLen($vakken_array[$i]) > 2 Then $CheckBox[$i] = GUICtrlCreateCheckbox("vk" & $i, 175, $top, 50, 20) $count += 1 $top += 20 EndIf Next $top = 50 For $i = 16 To 20 If StringLen($vakken_array[$i]) > 2 Then $CheckBox[$i] = GUICtrlCreateCheckbox("vk" & $i, 240, $top, 50, 20) $count += 1 $top += 20 EndIf Next $top = 50 For $i = 21 To 25 If StringLen($vakken_array[$i]) > 2 Then $CheckBox[$i] = GUICtrlCreateCheckbox("vk" & $i, 305, $top, 50, 20) $count += 1 $top += 20 EndIf Next $top = 50 For $i = 26 To 30 If StringLen($vakken_array[$i]) > 2 Then $CheckBox[$i] = GUICtrlCreateCheckbox("vk" & $i, 370, $top, 50, 20) $count += 1 $top += 20 EndIf Next with something like this: $left = 45 For $i = 0 To 5 $top = 50 For $j = 1 To 5 $k = $i * 5 + $j If StringLen($vakken_array[$k]) > 2 Then $CheckBox[$k] = GUICtrlCreateCheckbox("vk" & $k, $left, $top, 50, 20) $count += 1 $top += 20 EndIf Next $left += 65 Next Edited February 8, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
PcExpert Posted February 8, 2009 Author Share Posted February 8, 2009 (edited) @Melba23 I just like it, I ask a question and within a short time, I have the answer. So, please dont keep quiet next time;) . I'm glad that you like the 'vakken's' and that you are interested in the code . @Spiff59 I'll try that loop in my next version. Thanks for noticing Edited February 8, 2009 by PcExpert 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