On Saturday, March 29, 2003, at 05:43 PM, Thomas Tempelmann wrote:
Richard Altenburg wrote:
for i = f.count downto 1
deleteAnything(f.trueitem(i))
next
This is also a bad idea:
Some disks (file systems) may not be able to report the
correct file count (might be true for FAT, and even
UFS), so they'd either return a too high or too low
number.
The only safe way is to count up, starting at 1,
and check if a delete failed, thus increasing the
number by one, until one gets to a nil folderitem,
which means you're at the end of the list.
(CC'd to Matt, since this snipped was said to come from
his book)
Of all the filesystems I've had the pleasure of dealing with counting
backwards from count to 1 seems to be, in my experience, the least
likely to cause problems
Counting up has issues because one you delete item 1, item 2 is now
item 1 and you will only delete half the items
This has been discussed numerous times on this list
In this case you'd be better off to ALWAYS delete item 1 until item 1
is nil
---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>
Unsubscribe:
<mailto:realbasic-nug-off at lists dot realsoftware dot com>
Subscribe to the digest:
<mailto:realbasic-nug-digest at lists dot realsoftware dot com>
.
|