realbasic-nug
[Top] [All Lists]

Re: A quick question about folderitem.movefileto

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: A quick question about folderitem.movefileto
From: Joe Strout <joe at inspiringapps dot com>
Date: Thu, 31 Jan 2008 16:35:18 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <f72ec0cb0801311527n14a79001ib02485f759c53d4b at mail dot gmail dot com>
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>


<Prev in Thread] Current Thread [Next in Thread>