home *** CD-ROM | disk | FTP | other *** search
/ Software Du Jour / SoftwareDuJour.iso / BUSINESS / DBASE / DBASEIII.ARC / CATALOG.PRG next >
Encoding:
Text File  |  1985-01-24  |  2.8 KB  |  83 lines

  1. * CATALOG.PRG by Darryl Rubin, November, 1984.
  2. *
  3. * For more information about this program, see COMPUTER LANGUAGE
  4. * MAGAZINE, January, 1985.
  5. *
  6. * This program appends the directory for a specified path to a
  7. * specified catalog database.  The program is called with two
  8. * string arguments as follows:  DO CATALOG WITH PATHSPEC,CATNAME
  9. *
  10. * The PATHSPEC is any valid pathame recognized by DOS;  it may
  11. * include a drive designator.  The CATNAME is the filename part
  12. * (sans .DBF extension) of the catalog database to which the
  13. * directory is to be appended.  For example:
  14. *
  15. * DO CATALOG WITH "A:\","CATALOG"
  16. *
  17. * This program requires three database files with the following structure:
  18. *
  19. * CATSPEC: LINE - C 80
  20. * CATWORK: NAME - C 9; EXT - C 4; SIZE - C 10; DATE, TIME - C 8.
  21. * CATNEW:  Like CATWORK, but DATE is D and add VOL - C 11, PATH - C 29
  22. *
  23. * CATSPEC and CATWORK are intermediate working files.  CATNEW is
  24. * the structure model for the final output; it includes fields for
  25. * file name, extension, size, date, time, volume name, and path name.
  26. *
  27. * The program will run faster if you delete all the comments.
  28. *
  29. parameters pathspec,catfile
  30. close databases
  31. select 1
  32. use catspec
  33. set talk off
  34. set safety off
  35. zap
  36. *1: Call DOS to put the desired directory into file CATDIR.TXT
  37. if file('catdir.txt')
  38.   erase catdir.txt
  39. endif
  40. cmd = 'dir ' + pathspec + '>catdir.txt'
  41. run &cmd
  42. *2: Specified path bad if CATDIR.TXT not found or < 3 records long.
  43. if file('catdir.txt')
  44.   append from catdir.txt for recno() <= 3 sdf
  45.   if recno() >= 3
  46.     goto 2
  47. *3: Path is AOK, extract Volume and Path names from directory listing
  48.     voln = upper(trim(substr(line,23,11)))
  49.     goto 3
  50.     pathn = upper(trim(substr(line,at('\',line),29)))
  51. *4: Now prepare a temp database and read the directory into it
  52.     copy file catwork.dbf to cattemp.dbf
  53.     use cattemp alias temp
  54.     append from catdir.txt sdf
  55.     set filter to size > 0
  56.     select 2
  57. *5: If the specified catalog doesn't exist, create it.
  58.     if .not. file('&catfile..dbf')
  59.       copy file catnew.dbf to &catfile..dbf
  60.     endif
  61.     use &catfile
  62.     goto bottom
  63.     select temp
  64.     goto top
  65. *6: Read cattemp into catalog, reformatting date & adding vol/path
  66.     do while .not. eof()
  67.       select &catfile
  68.       append blank
  69.       replace name with temp->name, ext with temp->ext,         ;
  70.               size with temp->size, date with ctod(temp->date), ;
  71.               time with substr(temp->time,3), vol with voln,    ;
  72.               path with pathn
  73.       select temp
  74.       skip
  75.     enddo
  76.   endif
  77. endif
  78. close databases
  79. erase catdir.txt
  80. erase cattemp.dbf
  81. set safety on
  82. set talk on
  83.