Posted: Wed Sep 04, 2002 1:25 pm
Restored from previous forum. Originally posted by Fangbeast.
Is there a way of synchronising (easily) a ListIconGadget and a Linked list for all sorts of operations?
I have 3 loops below which should be able to do the same thing in one but I can't get it right.
First loop marks items in a linked list according to what items are tagged in the display (content()\tag). Second loop then deletes a file on disk according to the filename in Content()\diskfile and then deletes the tagged record itself. Third loop then deletes the tagged items in the display itself.
There has got to be a better way of doing this but my brain has left me tonight and I need help please anyone
:)
I've now got the below but it crashes. As I said, I don't really know how to do this any other way.
[/b]
Is there a way of synchronising (easily) a ListIconGadget and a Linked list for all sorts of operations?
I have 3 loops below which should be able to do the same thing in one but I can't get it right.
First loop marks items in a linked list according to what items are tagged in the display (content()\tag). Second loop then deletes a file on disk according to the filename in Content()\diskfile and then deletes the tagged record itself. Third loop then deletes the tagged items in the display itself.
There has got to be a better way of doing this but my brain has left me tonight and I need help please anyone
Code: Select all
For Loopy = 0 To CountGadgetItems(#ListBox)
If GetGadgetItemState(#ListBox, Loopy) & #PB_ListIcon_Checked
SelectElement(content(), Loopy)
content()\tag = 1
EndIf
Next Loopy
ResetList(content())
While NextElement(content())
If content()\tag = 1
DeleteFile(content()\diskfile)
DeleteElement(content())
EndIf
Wend
For Loopy = 0 To CountGadgetItems(#ListBox)
If GetGadgetItemState(#ListBox, Loopy) & #PB_ListIcon_Checked
RemoveGadgetItem(#ListBox, Loopy)
counter - 1
Loopy - 1
EndIf
Next Loopy
[b]
Code: Select all
listitems = CountGadgetItems(#ListBox) - 1
ResetList(content())
For Loopy = 0 To listitems
SelectElement(content(), Loopy)
If GetGadgetItemState(#ListBox, Loopy) & #PB_ListIcon_Checked
If content()\record = GetGadgetItemText(content(), Loopy, 0)
DeleteFile(content()\diskfile)
DeleteElement(content())
RemoveGadgetItem(#ListBox, Loopy)
counter - 1
Loopy = Loopy - 1
PreviousElement(content())
StatusBarText(#MyStatusBar, 0, "Deleting " + content()\diskfile, 0)
StatusBarText(#MyStatusBar, 1, "Files: " + Str(counter), 0)
EndIf
EndIf
Next Loopy