Hi Keith,

of course you'd be better off, when using either

getlistoffiles: func [dir /local dirlist][
      dirlist ......

or

getlistoffiles: function [dir][dirlist][
      dirlist ......


regarding the appearance of the links, Carl once
proposed, that 'to-file would create a string looking
right for the respective platform, I'm not sure, wether
it already works, but try: append filelist rejoin [to-file dir item]

And last, I think you should use 
dir? join dir item


regards,

Ingo


Once upon a time [EMAIL PROTECTED] spoketh thus:
> 
> 
> [EMAIL PROTECTED] wrote:
> 
> > Hi, I'm need an HTML listing of all files in a given directory tree (not
> > necessarily starting at the root level).
> >
> > Here's some preliminary code I've written so far while I've been doing other
> > work:
> >
> > starting_directory: %/c/
> >
> > filelist: []
> >
> > getlistoffiles: func [dir][
> >     dirlist: read dir
> >     foreach item dirlist [
> >         either not dir? item [
> >             append filelist rejoin [dir item]
> >         ][
> >             getlistoffiles item
> 
> be carefull with recursions ... your 'dirlist word's gonna be "global" for all
> your "getlistoffiles item" calls. Try:
> 
> getlistoffiles: func [dir][dirlist][
>       dirlist ......
> 
> which will define 'dirlist as a local word to your function ....
> 
> 
> >
> >         ]
> >     ]
> > ]
> >
> > getlistoffiles starting_directory
> >
> > print ["<html><head><title>Every file in " starting_directory
> > "</title></head><body>"]
> >
> > foreach file filelist [
> >     print rejoin ["<a href=^"file://" file "^">" file "</a>"]
> > ]
> >
> > print "</body></html>"
> >
> > ---------------------------
> >
> > Once it's working I'm going to write the whole thing I'm just printing to
> > the console now to a file of course.
> >
> > Seems like it should be really simple, but I'm running into some problems.
> > For some reason it isn't "recursing" and getting the subdirectories, and
> > even though I have the "dir?" test in there it's still putting directories
> > in 'filelist. Also, since I'm on Windows, the "file" that I get from the
> > foreach at the bottom isn't good enough to put as an HTML link since it
> > doesn't have the colon in it. i.e. It looks like "file:///c/blahblah"
> > rather than "file:///c:/blahblah"
> >
> 
> Is it a problem? Well, you need to skip first three chars from your file (skip
> file 3) and insert the colon then :-):
> 
> foreach file filelist [
>     print rejoin ["<a href=^"file://" head insert skip file 2 ":" "^">" file
> "</a>"]
> ]
> 
> HopeThisHelps :-)
> 
> Cheers,
> -pekr-
> 
> >
> > If anyone could lend any assistance I'd be grateful. And of course if
> > someone's already written a script to do exactly this, if anyone could point
> > me to it it'd be great. Thanks!
> >
> > Keith
> 

--
                do http://www.2b1.de/
    _     .                                _
ingo@)|_ /|  _| _  <We ARE all ONE   www._|_o _   _ ._ _  
www./_|_) |o(_|(/_  We ARE all FREE> ingo@| |(_|o(_)| (_| 
                                             ._|      ._|

Reply via email to