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 / splitlit.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  55 lines

  1. ############################################################################
  2. #
  3. #    File:     splitlit.icn
  4. #
  5. #    Subject:  Program to create string literal
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     September 15, 1993
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  The idea is to create a string literal with continuations in case
  18. #  it's too long.
  19. #
  20. #  The options are:
  21. #
  22. #    -w i    width of piece on line, default 50
  23. #    -i i    indent, default 3
  24. #
  25. ############################################################################
  26. #
  27. #  Links:  options
  28. #
  29. ############################################################################
  30.  
  31. link options
  32.  
  33. procedure main(args)
  34.    local width, line, chunk, opts, prefix, indent
  35.  
  36.    opts := options(args, "w+i+")
  37.  
  38.    width := \opts["w"] | 50
  39.    indent := \opts["i"] | 3
  40.  
  41.    prefix := repl(" ", indent)
  42.  
  43.    while line := read() do {
  44.       line ? {
  45.          writes(prefix, "\"")
  46.          while chunk := move(50) do {
  47.             write(image(chunk)[2:-1], "_")
  48.             writes(prefix)
  49.             }
  50.          write(image(tab(0))[2:-1], "\"")
  51.          }
  52.      }
  53.  
  54. end
  55.