Sign in to follow this  
Followers 0
Zithen

for looping

3 posts in this topic

have this gui has 2 for loops, the frist one work great, but down in the case statment for hitting $DelBtnGo it will do the first msg box but never enter the for loop or just by passes it. I tried a few options but get the same results...

if someone can take a look and let me know what i screwed up that would be great thanks

Global $name
    Global $check[20]
    Global $delini
    Global $x = 10
    Global $y = 30
    
    
    $name = IniReadSectionNames($file)
    If @error Then
        MsgBox(48, "Error", "Error: Can not read save file." & @CR & @CR & "Error: 1084")
    Else
        GUICreate("Delete Printers", 400, 230)
        For $i = 1 To $name[0]
            $name1 = IniRead($file, $name[$i], "name", "null")
            $check[$i] = GUICtrlCreateCheckbox($name1, 10, $y, 200, 10)
            $y = $y + 20
        Next
        $DelLbl = GUICtrlCreateLabel("Please check the printers you would like to delete.", 80, 10, 250, 20)
        $DelBtnAll = GUICtrlCreateButton("Delete All", 100, 190, 70, 30)
        $DelBtnGo = GUICtrlCreateButton("Delete Selected", 210, 190, 85, 30)
    EndIf
    
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $DelBtnAll
                deleteallprinters()
            Case $msg = $DelBtnGo
                MsgBox(0,"test","1")
                For $i = 1 To $check[0]
                    MsgBox(0,"test","2")
                    $chb_state = GUICtrlRead($check[$i])
                    msgbox(0,"test",$chb_state)
                    If $chb_state = $GUI_CHECKED Then
                        MsgBox(0, "staus", "deleting" & $name[$i])
                    Else
                        MsgBox(0, "staus", "not deleting" & $name[$i])
                    EndIf
                Next
        EndSelect
    WEnd
    Exit

Share this post


Link to post
Share on other sites



have this gui has 2 for loops, the frist one work great, but down in the case statment for hitting $DelBtnGo it will do the first msg box but never enter the for loop or just by passes it. I tried a few options but get the same results...

if someone can take a look and let me know what i screwed up that would be great thanks

What is the value of $check[0], don't see you setting it anywhere ?

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

see i knew i screwed up lol i didint have it set...just added a simplie $check[0] = $i - 1 after my next statement and works like a charm lol.

thx JdeB

Share this post


Link to post
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
Sign in to follow this  
Followers 0