summaryrefslogtreecommitdiff
path: root/ipl/gprogs/fileimag.icn
blob: 1c46190327f39551744a1e24e8e312158efae01f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
############################################################################
#
#	File:     fileimag.icn
#
#	Subject:  Program to create GIF image of file text
#
#	Author:   Ralph E. Griswold
#
#	Date:     July 8, 1997
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program creates an image file for a text file.  The results are
#  unpredictable for binary files or files with control characters.
#
#  The image may be too large for a window.
#
#  Badly needed are options for the font.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################
#
#  Links:  wopen
#
############################################################################

link wopen

procedure main(args)
   local input, width, height, line

   input := open(args[1]) | stop("*** cannot open file")

   width := height := 0

   while line := read(input) do {
      height +:= 1
      width <:= *line
      }

   height +:= 1

   close(input)

   input := open(args[1]) | stop("*** cannot re-open file")

   WOpen("canvas=hidden", "columns=" || width, "lines=" || height) |
      stop("*** cannot open window")

   while WWrite(WRead(input))

   WriteImage("untitled.gif")


end