|
Posted by Curtis on 12/15/05 21:29
Ian B <ianbambury@gmail.com> wrote in message
news:1134648729.845932.57060@g44g2000cwa.googlegroups.com...
>
> Curtis wrote:
> > Any suggestions for a recursive algorithm that reads
text
> > file A line by line until it encounters a line directing
to
> > it read in a similar manner file B which might have
command
> > lines for reading files C and D, and so forth.
> >
> > It might look like so:
> >
> > A
> > A
> > A
> > A
> > A
> > READ B
> > B
> > B
> > READ C
> > C
> > C
> > B
> > B
> > A
> > A etc.
> >
> > The objective is to have one large array or string of
text
> > with the referenced files as includes. I think I can
manage
> > the recursive file opens, though I haven't tested code
yet.
> > Questions:
> >
> > Any limit to number of files? (Is file() the best
function
> > for this?)
> >
> > Best way to prevent circular references? (Place each
> > filename in an array with its calling file as a key
and...?)
> >
> > Guidance appreciated.
> Top of the head...
>
> pass an array (or make it global) and set an element with
a name set to
> the MD5 hash of the file name, then a simple isset() will
tell you if
> it has been used previously. Unset it on your way out of
the recursive
> call.
>
> Ian
Thanks, Ian. That's just about what I came up with... the
notion of a "path." I'll have to give the notion of a hash
of the file name some study, though. I don't know much about
those... don't know why that would be better than a simple
stack/array search, for example.
--
Curtis
Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.
>
Navigation:
[Reply to this message]
|