About chdir... and directory/file storage

John Esak john at valar.com
Thu Sep 2 09:15:26 PDT 2004


<top-post>

George,

That is simply the nicest thing anyone has said to me in a long time. Thanks
so much. I have learned a heck of a lot from you over the past years or so,
too. The admiration is mutual.

John Esak

> -----Original Message-----
> From: George Simon [mailto:george at worldest.com]
> Sent: Thursday, September 02, 2004 10:27 AM
> To: john at valar.com; filePro mailing list
> Subject: RE: About chdir... and directory/file storage
>
>
> John, I have absolutely no interest (at the present time) in what you are
> talking about here, but the time and effort you put into trying to help
> others. The clarity of your code examples, and the way you
> explain what you
> are doing and why you are doing it, is something that I have
> always admired.
> I want to publicly thank you for all the things you have taught
> me over the
> many years of simply reading your posts.  Keep up the good work
> and thanks a
> bunch!
>
> George Simon (IT Department)
> American River Logistics, LTD
> 614 Progress St.
> Elizabeth, NJ  07205
> Phone:(908)354-7746      Fax:(908)354-7491
> mailto:george at worldest.com
> http://www.americanriverintl.com/
>
>
>
> -----Original Message-----
> From: filepro-list-bounces at lists.celestial.com
> [mailto:filepro-list-bounces at lists.celestial.com]On Behalf Of John Esak
> Sent: Thursday, September 02, 2004 6:40 AM
> To: filePro mailing list
> Subject: About chdir... and directory/file storage
>
>
> Richard (and others),
>
> I know you may not be able to change your scheme for storing
> files from EDI,
> but this may help in some way... Here's how I do it. (As usual, I try and
> work _within_ filePro so there is no reliance on platform based
> utilities.)
>
> The problem of EDI and storing so much incoming data is very important. It
> is necessary to store the files that arrive daily in some manner
> that makes
> sense and can be dealt with easily as time goes by, days, months, years.
> That is why I took some time to develop this scheme. It has saved
> me untold
> headaches over the past several years. I have to deal with both
> DOS and Unix
> so it deals with the slash/backslash thing in a way that makes
> sense to me,
> in that it works on both sides. Admittedly, there are many
> different ways to
> handle this and there are times when a / will work equally well on both
> platforms... still, this is how I handled it. More to the point of the
> actual traversing of directories, I adopted the following procedure.
>
> On any day that files come into the system, I put them in a
> directory with a
> hierarchy of that year, that month and then that day with a batch number
> from 1 to 100, so that multiple incoming files for each day can be
> accommodated. To do this, I have filePro check to see if the full
> dirpath is
> already there, if so, I use it. If not, I create the path, whether it be
> just to add a new month to the current year, or to add a new year if it
> doesn't exist and then add the new month as well. Happily, the system has
> been working for quite some time now without any attendance from
> me. I have
> directories (and files) which look like this now and it is very easy to
> traverse them with filePro processes _and_ human-applied searches
> with "cd".
> I can find anything quickly by date and that is the name of the
> game. (Also,
> more importantly, they can be traversed by either Windows filePro or Unix
> filePro.) These are not exact portrayals of the directories created in the
> processing, but close, just to give you the idea...
>
>     /u/edi/ups/arch/inv/01/01/invbat01.dat
>     /u/edi/ups/arch/inv/01/01/invbat02.dat
>     /u/edi/ups/arch/inv/01/02/invbat01.dat
>     /u/edi/ups/arch/inv/01/02/invbat01.dat
>     /u/edi/ups/arch/inv/01/12/invbat01.dat
>     /u/edi/ups/arch/inv/02/01/invbat01.dat
>     /u/edi/ups/arch/inv/02/01/invbat02.dat
>     /u/edi/ups/arch/inv/02/02/invbat01.dat
>     /u/edi/ups/arch/inv/02/02/invbat01.dat
>     /u/edi/ups/arch/inv/02/12/invbat01.dat
> and
>     /u/edi/ups/arch/po/01/01/invbat01.dat
>     /u/edi/ups/arch/po/01/01/invbat02.dat
>     /u/edi/ups/arch/po/01/02/invbat01.dat
>     /u/edi/ups/arch/po/01/02/invbat01.dat
>     /u/edi/ups/arch/po/01/12/invbat01.dat
>     /u/edi/ups/arch/po/02/01/invbat01.dat
>     /u/edi/ups/arch/po/02/01/invbat02.dat
>     /u/edi/ups/arch/po/02/02/invbat01.dat
>     /u/edi/ups/arch/po/02/02/invbat01.dat
>     /u/edi/ups/arch/po/02/12/invbat01.dat
>
>
> Here is the processing which does the directory/file allocation. I hope it
> helps. Without doing things in this way, any data collection
> method would be
> extremely limited in helping "humans" to find files when required. If any
> part of this code is not understandable to anyone, feel free to ask.
>
>
>      filePro File: npi_edi_ups_run
>  Processing Table: quick
>     Last Modified: Thursday - Sep  2, 2004 at  6:09 AM
>        Documented: Thursday - Sep  2, 2004 at  6:11 AM
>
>     1  Then: end
> errout   If: 'errout
>     2  Then:
>     3  Then: close;  exit
> @once    If: '@once
>     4  Then:
>     5  Then: lookup ctrl=npi_edi_ups_ctl r=("1")
>     6  Then: declare sls(1);  sls=chr("92")
>     7  Then: declare rec_dl(1), fld_dl(1), seg_dl(1)
>     8  Then: 'fld_dl="^";  rec_dl="~";  seg_dl=">"
>     9  Then: fld_dl="*";  rec_dl="~";  seg_dl=">"
>    10  Then: declare DirShare, DirIn, DirOut, DirArc, DirArcCat, DirArcIn,
>              DirArcOut
>    11  Then: DirShare="u:";  DirIn="inbox";  DirOut="outbox";
> DirArc="archive"
>    12  Then: DirArcCat="inv"
>    13  Then: DirArcIn=DirArc{sls{DirArcCat{sls{"in";  DirArcOut=
>              DirArc{sls{DirArcCat{sls{"out"
>    14  Then: declare DosPathWork; DosPathWork=
>
> "c:"{sls{"progra~1"{sls{"peregrine"{sls{"trustedlink"{sls{"work"
>    15  Then: declare SysCommand
>    16  Then: declare DirStamp
>    17  Then: declare InStamp(8)
>    18  Then: declare InNum(3,.2), InDate(6,ymd)
>    19  Then: declare count(2,.0);  count="1"
>    20  Then: InDate=@td
>    21  Then: lookup bat = npi_edi_ups_invbatch  k=(InDate) i=a -nx
> morbat   If: not bat
>    22  Then: goto getit
>          If: bat(1) ne InDate
>    23  Then: goto getit
>    24  Then: count=count+"1";  getnext bat;  goto morbat
> getit    If: 'getit
>    25  Then:
>    26  Then: InNum=count/"100"
>    27  Then: lookup bat=npi_edi_ups_invbatch r=free
>    28  Then: bat(1)=InDate;  bat(2)=InNum;  write bat
>    29  Then: InStamp=InDate & mid(InNum,"2","2")
>    30  Then: 'test the dirs
>    31  Then: declare year(2),  month(2)
>    32  Then: Year=mid(InDate,"1","2");  Month=mid(InDate,"3","2")
>    33  Then: declare DirYear, DirMonth
>    34  Then: DirYear=DirShare { sls { DirArcIn { sls { Year
>    35  Then: DirMonth=DirShare { sls { DirArcIn { sls { Year { sls { Month
> tstYR    If: exists(DirYear) eq "1"
>    36  Then:
> tstMO    If: exists(DirMonth) eq "1"
>    37  Then:
>          If: not tstYR
>    38  Then: system noredraw "mkdir" < DirYear
>          If: not tstMO
>    39  Then: system noredraw "mkdir" < DirMonth
>    40  Then: declare FullPath1, FullPath2
>    41  Then: FullPath1=DosPathWork { sls { "output.dat"
>    42  Then: declare file_is_inv(1);  file_is_inv=""
>          If: 'maybe use later
>    43  Then: 'gosub tst4inv
>          If: 'file_is_inv eq "N"
>    44  Then: 'goto errout
>    45  Then: FullPath2=Dirshare { sls { DirIn { sls { "inv_infile.dat"
>    46  Then: SysCommand="copy" < FullPath1 < FullPath2
>          If: 'jje remove comment for production
>    47  Then: system SysCommand
>    48  Then: FullPath2=DirMonth { sls { InStamp { ".dat"
>    49  Then: SysCommand="copy" < FullPath1 < FullPath2
>          If: 'jje
>    50  Then: system SysCommand
>    51  Then: '
>    52  Then: 'file manipulation starts her
>    53  Then: declare infile(256), outfile(256)
>    54  Then: declare outline
>    55  Then: declare h_i(4,.0), h_o(4,.0), h_ow(4,.0),
> h_c(4,.0), h_s(8,.0)
>    56  Then: infile=DirShare { sls { DirIn { sls { "inv_infile.dat";
> outfile=
>              DirShare { sls { DirOut { sls { "inv.out1"
>    57  Then: '
>    58  Then: declare there(4,.0)
>    59  Then: there=exists(infile)
>          If: there eq "0"
>    60  Then: goto errout
>    61  Then: h_o=open(outfile,"rw0tc")
> loop     If:
>    62  Then: import ascii inf=(infile) f=255 r=~
>          If: not inf
>    63  Then: close inf;  h_c=close(h_o);  goto pass2
>          If: 'mid(inf(1),"1","3") eq "IEA"
>    64  Then: 'debug on
>          If: 'for files without newlines
>    65  Then: 'outline="" { inf(1) { rec_dl { chr("10") { ""
>          If: 'for files with newlines!  windows\stx32.ini newline=1
>    66  Then: outline="" { inf(1) { rec_dl { ""
>    67  Then: h_ow=write(h_o,outline)
>    68  Then: goto loop
>
>
>
>
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>



More information about the Filepro-list mailing list