Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Acquiring sub-dir contents

 [1/4] from: ddalley::idirect::com at: 11-Oct-2001 17:05


Hello, Christopher: Thanks. See my reply to Ryan. On 04-Oct-01, Christopher Ross-Gill wrote:
> This might be a useful starting point.
Hmm, this has some techniques that I don't understand, so I built something simpler. I see yours does a couple of different reads; someone may find that useful. There seems to be more sorting going on than necessary, too. One sort, after the block is built, should be enough, no? I also like the idea of using a function. -- ---===///||| Donald Dalley |||\\\===--- The World of AmiBroker Support http://webhome.idirect.com/~ddalley UIN/ICQ#: 65203020

 [2/4] from: ddalley:idirect at: 11-Oct-2001 16:42


Hello, Ryan & Christopher: Thanks to you both, for your ideas. On 04-Oct-01, Ryan Cole wrote:
> Does this do what you need? > get-sub-files: does [ > files: copy [] > foreach item read %. [ if dir? item [append files read item] ] > ]
Not on its own - I tried it "as is", after getting variable names synced, but it didn't work. Having said that, I didn't pursue it, to find out >why< it didn't work for me. The following is what I ended up using: ; get top drawer-list drawer-list: READ read-drawer cur-files: COPY [] all-files: COPY [] ; append each directory list into block FOREACH drawer drawer-list [ new-path: JOIN read-drawer drawer CHANGE-DIR new-path cur-files: READ %. all-files: APPEND all-files cur-files ] It reads the top drawer, for that drawer's list of directories, builds a new path for each sub-directory (there's only one sub level), changes its local path, then reads each sub-directory, appending its file names into a block. It's not smart, in the sense that it only deals with directories, but it does what I need, for now. A file in the top drawer will stop the run, though, so it most definitely can be improved. Making it into a function may be the next step, but I'll use it this way, for a while, first. -- ---===///||| Donald Dalley |||\\\===--- The World of AmiBroker Support http://webhome.idirect.com/~ddalley UIN/ICQ#: 65203020

 [3/4] from: ryanc:iesco-dms at: 11-Oct-2001 16:28


Hi Donald, mine only read the contents of each subdirectory in the current directory, so it could have overlooked the files you were trying to read. Christopher's recursive version should have produced results no matter what you threw at it. BTW you can reduce your code to this just by removing the temp variables by feeding functions into one another... ; append each directory list into block all-files: COPY [] FOREACH drawer READ read-drawer [ CHANGE-DIR JOIN read-drawer drawer APPEND all-files READ %. ] And a little more by changing the path and not the directory... ; append each directory list into block all-files: COPY [] FOREACH drawer READ read-drawer [ APPEND all-files READ JOIN read-drawer drawer ] And to stablize things... ; append each directory list into block all-files: COPY [] FOREACH drawer READ read-drawer [ if dir? JOIN read-drawer drawer [ APPEND all-files READ JOIN read-drawer drawer ] ] --Ryan Donald Dalley wrote:
> Hello, Ryan & Christopher: > Thanks to you both, for your ideas.
<<quoted lines omitted: 53>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400

 [4/4] from: ddalley:idirect at: 12-Oct-2001 0:50


On 11-Oct-01, Ryan Cole wrote:
> mine only read the contents of each subdirectory in the current directory, > so it could have overlooked the files you were trying to read. Christopher's > recursive version should have produced results no matter what you threw at
it.
> BTW you can reduce your code to this just by removing the temp variables by > feeding functions into one another...
Thanks for some useful ideas, Ryan. You quickly wrote some tight changes which illustrate REBOL ways, of which I was not aware. Over the next few days, I'll take a look at them, to see how I will apply them. -- ---===///||| Donald Dalley |||\\\===--- The World of AmiBroker Support http://webhome.idirect.com/~ddalley UIN/ICQ#: 65203020

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted