home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 24 DOS / 24-DOS.zip / dosrx10b.zip / LINES.R < prev    next >
Text File  |  1988-04-10  |  917b  |  34 lines

  1. /** count lines, by redirecting DIR command **/
  2. /** redirection can be avoided by using stacks
  3.  ** so, instead of "dir ...> file" we will use
  4.  ** "dir" arg(1) "(stack"
  5.  ** do queued    (instead of do until eof(file))
  6.  **    parse pull fn ft sz .
  7.  **    ....
  8.  ** and not "del" file  command at the end
  9.  **/
  10. call load "files.r"
  11. lines = 0
  12. size = 0
  13. file = "$$$fff$$$"
  14. "dir" arg(1) ">" file
  15. do until eof(file)
  16.    parse value read(file) with fn ft sz .
  17.    if pos('.',fn) then do     /* some shells display files as: */
  18.       sz = ft                 /* RX.EXE  57357  bla bla bla    */
  19.       parse var fn fn '.' ft
  20.    end
  21.    if datatype(size) ^= 'NUM' then iterate
  22.    f = fn'.'ft
  23.    call write ,"file" f
  24.    l = lines(f)
  25.  /*   sz = filesize(f) */
  26.    say format(l,5) format(s,6)
  27.    lines = lines + l
  28.    size = size + sz
  29. end
  30. say "total lines =" lines
  31. say "total size  =" size
  32. "del" file
  33. exit 0
  34.