> From: Jeffrey Ellis <[EMAIL PROTECTED]> > Date: Fri, 17 Mar 2006 20:46:24 -0800 > To: Jeffrey Ellis <[EMAIL PROTECTED]> > Conversation: realbasic-nug Digest, Vol 24, Issue 72 > Subject: Re: realbasic-nug Digest, Vol 24, Issue 72 > > At 4:30 PM -0800 3/17/06, "Joseph J. Strout" <joe at strout dot net> wrote: > > The above is functioning as expected when the Target list is missing a file > which exists in the Source list. But it breaks when a file is in the Target > which doesn't exist in the Source. Then, all the files after that don't > match, and it adds all files it finds until the end of the list. > > But I'm not sure how I can test for that instance? > > What you're attempting to do is a very complicated thing. If there could be > files missing in Target, or in Source, then when you find a mismatch, how do > you know which one is missing something? > > Though come to think of it, maybe it's not that hard, since you have a unique > identifier for each thing (the shell path, which is fine for a purpose like > this). So here's a general approach to the problem: > > 1. Make a function that recurses over a folder, and for every file it finds, > appends to two arrays: one gets the ShellPath and one gets the Name (or > DisplayName if you prefer). > > 2. Call this for your source and target volumes. So now you have four arrays, > srcPaths, srcNames, targPaths, and targNames. > > 3. Now iterate over these arrays, with a srcIndex and a targIndex. Hmm, I > tried to describe the next step in words, but pseudocode is clearer: > > srcPath = srcPaths( srcIndex ) > targPath = targPaths( destIndex ) > if srcPath = targPath then > // they match -- add them to the listboxes as a match, then: > srcIndex = srcIndex + 1 > destIndex = destIndex + 1 > else > if targPaths.IndexOf( srcPath ) < 0 then > // we have a file in source that's not in the target; > // add this to listboxes as a file added in the source, then: > srcIndex = srcIndex + 1 > end if > if srcPaths.IndexOf( targPath ) < 0 thne > // we have a file in the target that's not in the source; > // add this to listboxes as a file added in the target, then: > targPath = targPath + 1 > end if > end if > // now, repeat until done! > > I think that should pretty much do it. > > Good luck, > - Joe
Wow. First off, thank you for going into such detail about doing this... :) Unfortunately for me, this pretty much looks out of my level of RB education. Could you maybe step me through this? I just pasted in the recursion example, for instance. Although I understand the principle of recursion, I don't actually know how to execute such a function. All My Best, Jeffrey _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
