Jump to content

Tracking which items are filled/starting from that number


Damein
 Share

Recommended Posts

Sorry if the title is confusing.. I couldn't think of how to describe it..

Anyways, I have a GUI with 60 checkboxes. The person can select a file and it attaches said file to the Tooltip for that specific checkbox. How I want it to be handled is it will start at the first unchecked checkbox, and move on until the number of files selected reaches its max.

IE

User Selects 3 Files

Checkbox 1-3 are already checked (Files are attached to these)

Program selects checkboxes 4-6 and attaches the new files to those, while maintaining the checks on 1-3.

For $i = 1 To 60
        If $i = 21 Then
            $Y = 0
        EndIf
        If $i = 41 Then
            $Y = 0
        EndIf
        If $i <= 20 Then
            $Item[$i] = GuiCtrlCreateCheckbox($i, 10, 0+$Y)
            $Y += 20
        ElseIf $i <= 40 Then
            $Item[$i] = GuiCtrlCreateCheckbox($i, 80, 0+$Y)
            $Y += 20
        ElseIf $i <= 60 Then
            $Item[$i] = GuiCtrlCreateCheckbox($i, 150, 0+$Y)
            $Y += 20
        EndIf
    Next

This is how I have created the checkboxes, using arrays.

And then to handle the file selection, I have this. Now, it works for 1-3 checkboxes, but obviously since $i resets to 0 on a new file selection, it tries and just checks 1-3 (If three files were selected on the second run through) So it detects those are already checked, and stops there.

If $CurrentFile = "" Then
        MsgBox(48, "Error", "No file selected..")
    Else
        $String = StringSplit($CurrentFile, "|")
            For $i = 1 To $String[0]
                If $i = $String[0] Then
                    ExitLoop
                EndIf
                $File[$i] = $String[1] & "\" & $String[$i+1]
            Next
            For $i = 1 To 60
                $State = GuiCtrlRead($Item[$i])
                If $State = $GUI_UNCHECKED Then
                    If $File[$i] > "" Then
                    GuiCtrlSetState($Item[$i], $GUI_SHOW)
                    GuiCtrlSetTip($Item[$i], $File[$i])
                    GuiCtrlSetState($Item[$i], $GUI_CHECKED)
                EndIf
                EndIf
            Next
    EndIf

But what I need it to do is start $i at the next "available" checkbox, IE its not checked.

Thanks!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

I've made some progress in this, but am stuck on something.

I obviously need to add in a check to not exceed the array.. but I'm being stupid atm and can't think of it..

I currently can do it how I want it for the first run through, but on the second I exceed the dimensions of the the array.

If $CurrentFile = "" Then
        MsgBox(48, "Error", "No file selected..")
    Else
        $String = StringSplit($CurrentFile, "|")
        $FileCount = $String[0]-1
                    For $i = 1 To 60
                $State = GuiCtrlRead($Item[$i])
                If $State = $GUI_UNCHECKED Then
                    $StartingCount = $i
                    ExitLoop
                EndIf
            Next
            For $i = $StartingCount To $StartingCount + $FileCount - 1
                $File[$i] = $String[1] & "\" & $String[$i + 1]
            Next
            For $i = $StartingCount To 60
                $State = GuiCtrlRead($Item[$i])
                If $State = $GUI_UNCHECKED Then
                    If $File[$i] > "" Then
                    GuiCtrlSetTip($Item[$i], $File[$i])
                    GuiCtrlSetState($Item[$i], $GUI_CHECKED)
                EndIf
                EndIf
            Next
        EndIf

Now I have to use: $File[$i] = $String[1] & "" & $String[$i + 1] in order to prevent the String[0] (Showing the location of the files) from showing.

But, it exceeds the array because I need +1 on it. 

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Damein,

Instead of using

For $i = $StartingCount To 60

use

For $i = $StartingCount To ubound($item) - 1

use that same method for all for..to loops involving arrays (unless you use the element count in offset 0).  Hardcoding an array size will always bite you at some point.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I see, I will rememeber that. But, I still get the error of array dimension.

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...