Jump to content

Recommended Posts

Posted (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 by PcExpert
  • Moderators
Posted

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

EndFunc

This 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!

M23

P.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!

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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 by PcExpert
  • Moderators
Posted (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 by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Speaking of loops...

You could always replace:

For $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 by Spiff59
Posted (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 by PcExpert

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...