summaryrefslogtreecommitdiff
path: root/ipl/gprogs/floats.icn
blob: 9061c28e5931304389ed28fef0e1777803700f84 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
############################################################################
#
#	File:     floats.icn
#
#	Subject:  Program to count floats
#
#	Author:   Ralph E. Griswold
#
#	Date:     July 15, 2002
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program analyzes the floats in a drawdown as a BLP or row file
#  from standard input.
#
############################################################################
#
#  Links:  pattread, patxform
#
############################################################################

link pattread
link patxform

procedure main()
   local front, back, black, white

   front := pattread()
   
   back := pinvert(front)

   analyze("Front weft floats", front, "0")

   front := protate(front)

   analyze("Front warp floats", front, "1")
   analyze("Back weft floats", back, "0")

   back := protate(back)

   analyze("Back warp floats", back, "1")

end

procedure analyze(caption, rows, color)
   local counts, length, row

   counts := table(0)

   every row := !rows do {
         row ? {
            while tab(upto(color)) do {
               length := *tab(many(color))
            if length > 2 then counts[length] +:= 1
            }
         }
      }

   if *counts = 0 then return

   write(caption)

   counts := sort(counts, 3)

   write()

   while write("\t", get(counts), "\t", get(counts))

   write()

   return

end