home *** CD-ROM | disk | FTP | other *** search
- * CATALOG.PRG by Darryl Rubin, November, 1984.
- *
- * For more information about this program, see COMPUTER LANGUAGE
- * MAGAZINE, January, 1985.
- *
- * This program appends the directory for a specified path to a
- * specified catalog database. The program is called with two
- * string arguments as follows: DO CATALOG WITH PATHSPEC,CATNAME
- *
- * The PATHSPEC is any valid pathame recognized by DOS; it may
- * include a drive designator. The CATNAME is the filename part
- * (sans .DBF extension) of the catalog database to which the
- * directory is to be appended. For example:
- *
- * DO CATALOG WITH "A:\","CATALOG"
- *
- * This program requires three database files with the following structure:
- *
- * CATSPEC: LINE - C 80
- * CATWORK: NAME - C 9; EXT - C 4; SIZE - C 10; DATE, TIME - C 8.
- * CATNEW: Like CATWORK, but DATE is D and add VOL - C 11, PATH - C 29
- *
- * CATSPEC and CATWORK are intermediate working files. CATNEW is
- * the structure model for the final output; it includes fields for
- * file name, extension, size, date, time, volume name, and path name.
- *
- * The program will run faster if you delete all the comments.
- *
- parameters pathspec,catfile
- close databases
- select 1
- use catspec
- set talk off
- set safety off
- zap
- *1: Call DOS to put the desired directory into file CATDIR.TXT
- if file('catdir.txt')
- erase catdir.txt
- endif
- cmd = 'dir ' + pathspec + '>catdir.txt'
- run &cmd
- *2: Specified path bad if CATDIR.TXT not found or < 3 records long.
- if file('catdir.txt')
- append from catdir.txt for recno() <= 3 sdf
- if recno() >= 3
- goto 2
- *3: Path is AOK, extract Volume and Path names from directory listing
- voln = upper(trim(substr(line,23,11)))
- goto 3
- pathn = upper(trim(substr(line,at('\',line),29)))
- *4: Now prepare a temp database and read the directory into it
- copy file catwork.dbf to cattemp.dbf
- use cattemp alias temp
- append from catdir.txt sdf
- set filter to size > 0
- select 2
- *5: If the specified catalog doesn't exist, create it.
- if .not. file('&catfile..dbf')
- copy file catnew.dbf to &catfile..dbf
- endif
- use &catfile
- goto bottom
- select temp
- goto top
- *6: Read cattemp into catalog, reformatting date & adding vol/path
- do while .not. eof()
- select &catfile
- append blank
- replace name with temp->name, ext with temp->ext, ;
- size with temp->size, date with ctod(temp->date), ;
- time with substr(temp->time,3), vol with voln, ;
- path with pathn
- select temp
- skip
- enddo
- endif
- endif
- close databases
- erase catdir.txt
- erase cattemp.dbf
- set safety on
- set talk on