2017-09-09 20:10:02 (edited by Ethin 2017-09-09 20:12:18)

Hello all,
I'm trying to loop through the contents of a list view gadget in PB 5.60 so that I can add the paths to a pack file. Unfortunately, when I go to do it after the app starts, it freezes, and I'm not sure why. I've registered the LZMA packer plugin and created the packs with compression level 9. (Even with compression level 0 it still freezes when I go to actually write the pack files.) Here's my looping code:

                      For i = 0 To CountGadgetItems (sounds)-1
                        AddPackFile (0, GetGadgetItemText (sounds, i, 0), GetFilePart (GetGadgetItemText(sounds, i, 0)))
                    Next
                    For i = 0 To CountGadgetItems (tsounds)-1
                                            AddPackFile (1, GetGadgetItemText(tsounds, i, 0), GetFilePart (GetGadgetItemText(tsounds, i, 0)))
                    Next

I'm wondering exactly what I'm doing wrong. I initialize my ListViewGadget like so:

sounds = ListViewGadget(#PB_Any, 5, 5, 120, 120)

I can add all the files to the gadget that I need -- it prompts me for a list of files to add right now -- like so:

        file$ = OpenFileRequester ("Select sound files to add", "", "Waveform Audio File Format (WAVE/WAV) sounds (*.wav;*.wave)|*.wav;*.wave", 0, #PB_Requester_MultiSelection)
                  If file$
        While file$
          AddGadgetItem (sounds, CountGadgetItems(sounds), file$)
          file$ = NextSelectedFileName()
        Wend
                MessageRequester ("Done", Str(CountGadgetItems(sounds)) + " sound(s) added successfully.", #PB_MessageRequester_Info)
                Else
                      MessageRequester ("Warning", "Warning SM6228: Operation cancelled by user.", #PB_MessageRequester_Warning)
                    EndIf

But actually compressing the pack file doesn't work:

                    If CreatePack (0, "nsounds.spk", #PB_PackerPlugin_Lzma, 9) And CreatePack (1, "tsounds.spk", #PB_PackerPlugin_Lzma, 9)
                      For i = 0 To CountGadgetItems (sounds)-1
                        AddPackFile (0, GetGadgetItemText (sounds, i, 0), GetFilePart (GetGadgetItemText(sounds, i, 0)))
                    Next
                    For i = 0 To CountGadgetItems (tsounds)-1
                                            AddPackFile (1, GetGadgetItemText(tsounds, i, 0), GetFilePart (GetGadgetItemText(tsounds, i, 0)))
                    Next
                    ClosePack (0)
                    ClosePack (1)
                    MessageRequester ("Done", "The sounds have been written and the packs compressed.", #PB_MessageRequester_Info)
                  Else
                    MessageRequester ("Error", "Cannot create the pack.", #PB_MessageRequester_Error)
                    EndIf

Can anyone help me solve this little issue? It's been a while since I last wrote in PureBASIC and that may be why I'm getting stuck like this.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2017-09-09 21:40:42

Update: I just figured this out on my own. Nevermind!

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github