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

  1. ############################################################################
  2. #
  3. #    File:     fileimag.icn
  4. #
  5. #    Subject:  Program to create GIF image of file text
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     July 8, 1997
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program creates an image file for a text file.  The results are
  18. #  unpredictable for binary files or files with control characters.
  19. #
  20. #  The image may be too large for a window.
  21. #
  22. #  Badly needed are options for the font.
  23. #
  24. ############################################################################
  25. #
  26. #  Requires:  Version 9 graphics
  27. #
  28. ############################################################################
  29. #
  30. #  Links:  wopen
  31. #
  32. ############################################################################
  33.  
  34. link wopen
  35.  
  36. procedure main(args)
  37.    local input, width, height, line
  38.  
  39.    input := open(args[1]) | stop("*** cannot open file")
  40.  
  41.    width := height := 0
  42.  
  43.    while line := read(input) do {
  44.       height +:= 1
  45.       width <:= *line
  46.       }
  47.  
  48.    height +:= 1
  49.  
  50.    close(input)
  51.  
  52.    input := open(args[1]) | stop("*** cannot re-open file")
  53.  
  54.    WOpen("canvas=hidden", "columns=" || width, "lines=" || height) |
  55.       stop("*** cannot open window")
  56.  
  57.    while WWrite(WRead(input))
  58.  
  59.    WriteImage("untitled.gif")
  60.  
  61.  
  62. end
  63.