home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / streamer.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  53 lines

  1. ############################################################################
  2. #
  3. #    File:     streamer.icn
  4. #
  5. #    Subject:  Program to append lines of file into one long line
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 12, 1995
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program outputs one long line obtained by concatenating the
  18. #  lines of the input file.
  19. #
  20. #  The supported options are:
  21. #
  22. #    -l i    stop when line reaches or exceeds i; default no limit
  23. #    -s s    insert s after each line; default no separator
  24. #
  25. #  Separators are counted in the length limit.
  26. #
  27. ############################################################################
  28. #
  29. #  Links:  options
  30. #
  31. ############################################################################
  32.  
  33. link options
  34.  
  35. procedure main(args)
  36.    local opts, length, line, limit, sep, ssize
  37.  
  38.    opts := options(args, "l+s:")
  39.    limit := opts["l"]
  40.    sep := \opts["s"] | ""
  41.    ssize := *sep
  42.  
  43.    length := 0
  44.  
  45.    while line := writes(read(), sep) do {
  46.       length +:= *line + ssize
  47.       if length >= \limit then break
  48.       }
  49.  
  50.    write()
  51.  
  52. end
  53.