realbasic-nug
[Top] [All Lists]

Re: Copying a folder

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Copying a folder
From: Thomas Tempelmann <listuser at tempel dot org>
Date: Sat, 31 Jul 2004 22:14:53 +0200
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Austin Clow wrote:

>you need to use
>
>dim i,c as integer
>dim j as FolderItem
>c=j.count
>
>
>//if you are moving the files from the folder j then you need to use
>
>for i=1 to c
>f=item(1)
>next
>
>the reason for this is because if you move the item out of the folder 
>"j" then the item will be gone and the count will no longer be equal to 
>the first time you said count it will get smaller each time it passes 
>through the loop.

Nonsense. If he'd really move the files (or delete them) yours
is not better than doing

   for i=1 to j.count

In both cases, you'd end up skipping some items.

And you must not rely on Count anyways, since in the loop some
other process could change the number of items in the dir and
then you'd go wrong, again. The safest way is to loop until f becomes
nil.

And to answer Andrew's original question:

Andrew, if you look at a "f" var that you've previously
gotten using j.Item(idx), then it'll never be an Alias,
because Item() would have already followed (resolved) the
alias. Instead, you must make sure you're always using
TrueItem in the loop. Then you'll get items that can be
an Alias, so you can skip them.

Thomas


-- 
Thomas Tempelmann,
http://www.tempel.org/rb/
http://www.tempel.org/software/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

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