On Jan 31, 2008, at 4:27 PM, Paul Rehill wrote:
> If I move all the files in a folder to another folder using
> folderitem.movefileto, is it best to cycle through a loop from the
> last item count to 1
>
> For j = iCountFoldItems downto 1
> SomeFolder.Item(j).movefileto SomeFolderElsewhere
> Next
Yes. Or, count forward, but always move Item(1) instead of Item(j).
> Counting the other way doesn't seem to work as it appears half the
> folderitems get moved as the item numbers of the files yet to be moved
> decrease accordingly.
Quite right. Suppose there are 10 files, and you're looping forward
>from 1 to 10. First you move file 1, so now there are 9 files,
numbered 1 through 9. Then you move file 2, leaving 1-8, and then
you move file 3, leaving 1-7, and then 4, leaving 1-6, and then 5,
leaving 1-5, and then you get to 6, but there is no file 6. Files
1-5 are left behind. You skipped over them, by incrementing your
counter every time while the file numbers were shifting down.
Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|