Opendir
Fairlight
fairlite at fairlite.com
Thu May 31 01:05:37 PDT 2018
Okay, looking at the OPENDIR online manual page right now.
I remember some of this from past threads.
By default, if you supply nothing, it gives you the processing tables for
the current filePro file. The first field is a mask, and they have those
named macros there. PRC_MASK gives you the same as nothing (but
potentially for another file, if you specify one). TOK_MASK would only
give you the *.tok files, etc.
I'm working on assumptions and extrapolations here, but I'd try one of
these two things to get an idea of what it can do:
n = opendir("","/tmp")
or
n = opendir("*","/tmp")
I'm guessing you want the latter, based on the fact that they provide the
"*.htm" literal string example, rather than a predefined mask.
Whether it only honours filePro file locations for the second argument, or
will honour arbitrary paths is entirely another kettle of fish. Only way
to know is to test.
As far as traversing directories, I'm not sure which meaning you're using.
If you mean simply opening an arbitrary directory outside of PFDIR, God
only knows. If you mean starting in one and combing the entire tree, no,
you can't do that all on the same filehandle in -any- language I've ever
seen. You need to do a fresh opendir() on every directory you want to
process, grab the dirents, see if they're directories, and then open each
one in turn and process them similarly. In a structured language, this
can be handled easily with recursive functions/subroutines. It's going to
be bitchier to do in filePro due to non-lexically-scoped variable names,
and code structure/flow. Even using the new nested CALLs, the lack of
lexical scoping is going to be IssueMatic[tm] unless you only ever have one
directory opened at any given time, which is not the usual idiom. You
can't reliably stack an array with the information if you think you'll ever
have more than 999 entries in a directory, either, so we're backto
IssueMatic[tm].
Recursive directory traversal isn't a task filePro was actually designed to
handle gracefully.
mark->
On Thu, May 31, 2018 at 04:01:35PM +1000, Ken Cole thus spoke:
> Thanks Mark
>
> From the online manual opendir can take 1,2 or no parameters. Hard to
> know what the value in field 1 is in the supplied example.
>
> Does it open the current directory?
>
> Can I use it to traverse directories in the current directory?
>
> Ken
>
> On Thu, 31 May 2018 at 1:06 pm, Fairlight via Filepro-list
> <[1]filepro-list at lists.celestial.com> wrote:
>
> It works with any directory, AFAIK.
> 4.8 NEXTDIR      Returns system directory info. Used
> with OPENDIR
> Â Â Â Syntax:
> Â Â Â Â Â Â XX = NextDir()
> Â Â Â Return Value - System directory information as follows:
> Â Â Â Â Â Â filename extension size date time fullname
> Â Â Â Â Â Â Â Â 14Â Â Â Â 10Â Â Â 14Â Â 8Â Â 6Â Â
> Â 25
> Â Â Â Notes: A single space is returned between each portion of
> the string.
> Â Â Â Â Â Â Â Filenames, extensions, and fullname are left
> justified. Size
> Â Â Â Â Â Â Â is right justified w/commas. The date and time
> right justified.
> Â Â Â Â Â Â Â NextDir() can be executed more than once to
> build a list of
> Â Â Â Â Â Â Â files for sub-directory structures.
> Â Â Â Example:
> Â Â Â Â @wlf1Â If: 1 gt ""Â Â Â Â Â Â Â ' check field 1
> gt ""
> Â Â Â Â Â Â Â Then: n = OPENDIR(1)Â Â Â ' n = the number of
> dir entries
>     ad2c  If: c lt n       ' c (counter) LT
> number of dir entries
> Â Â Â Â Â Â Â Then: c(4,.0)=c+"1"Â Â Â Â ' add "1" to the
> counter
>         If: not ad2c      ' no more
> directory entries
>        Then: n = CLOSEDIR();end ' n = "0" if properly
> closed
> Â Â Â Â Â Â Â Then: fn(25) = NEXTDIR()Â ' return directories
> or filename & ext.
> Â Â Â Â Â Â Â Then: show "@The directory or filename.ext is:
> "<fn;goto ad2c
> Don't even start me on the artificially low length limitations.
> m->
> On Thu, May 31, 2018 at 12:29:42PM +1000, Ken Cole via Filepro-list
> thus spoke:
> > Does opendir only work on the filePro directory?
> >
> > If not, how do you get it to return a list if all directories in
> the
> > current directory?
> >
> > Thanks
> >
> > Ken
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL:
> <[2]http://mailman.celestial.com/pipermail/filepro-list/attachments/
> 20180531/258d9ca3/attachment.html>
> > _______________________________________________
> > Filepro-list mailing list
> > [3]Filepro-list at lists.celestial.com
> > Subscribe/Unsubscribe/Subscription Changes
> > [4]http://mailman.celestial.com/mailman/listinfo/filepro-list
> >
> --
> Audio panton, cogito singularis.
> _______________________________________________
> Filepro-list mailing list
> [5]Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> [6]http://mailman.celestial.com/mailman/listinfo/filepro-list
>
> References
>
> 1. mailto:filepro-list at lists.celestial.com
> 2. http://mailman.celestial.com/pipermail/filepro-list/attachments/20180531/258d9ca3/attachment.html
> 3. mailto:Filepro-list at lists.celestial.com
> 4. http://mailman.celestial.com/mailman/listinfo/filepro-list
> 5. mailto:Filepro-list at lists.celestial.com
> 6. http://mailman.celestial.com/mailman/listinfo/filepro-list
--
Audio panton, cogito singularis.
More information about the Filepro-list
mailing list