Small.
[ir-tcl-moved-to-github.git] / formats / medium.tcl
1 # IR toolkit for tcl/tk
2 # (c) Index Data 1995
3 # See the file LICENSE for details.
4 # Sebastian Hammer, Adam Dickmeiss
5 #
6 # $Log: medium.tcl,v $
7 # Revision 1.10  1996-01-11 09:31:05  quinn
8 # Small.
9 #
10 # Revision 1.9  1995/10/17  14:18:10  adam
11 # Minor changes in presentation formats.
12 #
13 # Revision 1.8  1995/10/17  10:58:09  adam
14 # More work on presentation formats.
15 #
16 # Revision 1.7  1995/10/16  17:01:03  adam
17 # Medium presentation format looks better.
18 #
19 # Revision 1.6  1995/09/20  11:37:06  adam
20 # Work on GRS.
21 #
22 # Revision 1.5  1995/06/22  13:16:29  adam
23 # Feature: SUTRS. Setting getSutrs implemented.
24 # Work on display formats.
25 #
26 # Revision 1.4  1995/06/14  12:16:42  adam
27 # Minor presentation format changes.
28 #
29 # Revision 1.3  1995/06/13  14:39:06  adam
30 # Fix: if {$var != ""} doesn't work if var is a large numerical!
31 # Highlight when line format is used.
32 #
33 # Revision 1.2  1995/06/12  15:18:10  adam
34 # Work on presentation formats. These are used in the main window as well
35 # as popup windows.
36 #
37 #
38 proc display-grs-medium {w r i} {
39     foreach e $r {
40         for {set j 0} {$j < $i} {incr j} {
41             insertWithTags $w "  " marc-tag
42         }
43         insertWithTags $w "([lindex $e 0]:[lindex $e 2]) " marc-tag
44         if {[lindex $e 3] == "string"} {
45             insertWithTags $w [lindex $e 4] {}
46             insertWithTags $w "\n"
47         } elseif {[lindex $e 3] == "subtree"} {
48             insertWithTags $w "\n"
49             display-grs-medium $w [lindex $e 4] [expr $i+1]
50         } else {
51             insertWithTags $w [lindex $e 4] {}
52             insertWithTags $w " ?\n" {}
53         }
54     }
55 }
56
57 proc display-medium {sno no w hflag} {
58     if {$hflag} {
59         insertWithTags $w " $no " marc-head
60         insertWithTags $w "\n"
61     } else {
62         $w delete 0.0 end
63     }
64     set type [z39.$sno type $no]
65     if {$type == "SD"} {
66         set err [lindex [z39.$sno diag $no] 1]
67         set add [lindex [z39.$sno diag $no] 2]
68         if {$add != {}} {
69             set add " :${add}"
70         }
71         insertWithTags $w "Error ${err}${add}\n" marc-id
72         return
73     }
74     if {$type != "DB"} {
75         return
76     }
77     set rtype [z39.$sno recordType $no]
78     if {$rtype == "SUTRS"} {
79         insertWithTags $w [join [z39.$sno getSutrs $no]] {}
80         $w insert end "\n"
81         return
82     } 
83     if {$rtype == "GRS1"} {
84         display-grs-medium $w [z39.$sno getGrs $no] 0
85         return
86     }
87     if {[catch {set i [z39.$sno getMarc $no field 245 * a]}]} {
88         insertWithTags $w "Unknown record type: $rtype\n" marc-id
89         return
90     }
91     if {"x$i" != "x"} {
92         insertWithTags $w "Title " marc-pref
93         insertWithTags $w [string trimright [lindex $i 0] /] marc-text
94         set i [z39.$sno getMarc $no field 245 * b]
95         if {"x$i" != "x"} {
96             insertWithTags $w [string trimright [lindex $i 0] /] marc-text
97         }
98         $w insert end "\n"
99     }
100     set i [z39.$sno getMarc $no field 700 * a]
101     if {"x$i" == "x"} {
102         set i [z39.$sno getMarc $no field 100 * a]
103     }
104     if {"x$i" != "x"} {
105         if {[llength $i] > 1} {
106             insertWithTags $w "Authors " marc-pref
107         } else {
108             insertWithTags $w "Author " marc-pref
109         }
110         foreach x $i {
111             insertWithTags $w $x marc-it
112         }
113         $w insert end "\n"
114     }
115     set i [z39.$sno getMarc $no field 110 * *]
116     if {"x$i" != "x"} {
117         insertWithTags $w "Co-Author " marc-pref
118         foreach x $i {
119             insertWithTags $w $x marc-text
120         }
121         $w insert end "\n"
122     }
123
124     set i [z39.$sno getMarc $no field 650 * *]
125     if {"x$i" != "x"} {
126         set n 0
127         insertWithTags $w "Keywords " marc-pref
128         foreach x $i {
129             if {$n > 0} {
130                 $w insert end ", "
131             }
132             insertWithTags $w $x marc-it
133             incr n
134         }
135         $w insert end "\n"
136     }
137     set i [concat [z39.$sno getMarc $no field 260 * a] \
138             [z39.$sno getMarc $no field 260 * b]]
139     if {"x$i" != "x"} {
140         insertWithTags $w "Publisher " marc-pref
141         foreach x $i {
142             insertWithTags $w $x marc-text
143         }
144         $w insert end "\n"
145     }
146     set i [z39.$sno getMarc $no field 020 * a]
147     if {"x$i" != "x"} {
148         insertWithTags $w "ISBN " marc-pref
149         foreach x $i {
150             insertWithTags $w $x marc-text
151         }
152         $w insert end "\n"
153     }
154     set i [z39.$sno getMarc $no field 022 * a]
155     if {"x$i" != "x"} {
156         insertWithTags $w "ISSN " marc-pref
157         foreach x $i {
158             insertWithTags $w $x marc-text
159         }
160         $w insert end "\n"
161     }
162     set i [z39.$sno getMarc $no field 030 * a]
163     if {"x$i" != "x"} {
164         insertWithTags $w "CODEN " marc-pref
165         foreach x $i {
166             insertWithTags $w $x marc-text
167         }
168         $w insert end "\n"
169     }
170     set i [z39.$sno getMarc $no field 015 * a]
171     if {"x$i" != "x"} {
172         insertWithTags $w "Ctl number " marc-pref
173         foreach x $i {
174             insertWithTags $w $x marc-text
175         }
176         $w insert end "\n"
177     }
178     set i [z39.$sno getMarc $no field 010 * a]
179     if {"x$i" != "x"} {
180         insertWithTags $w "LC number " marc-pref
181         foreach x $i {
182             insertWithTags $w $x marc-text
183         }
184         $w insert end "\n"
185     }
186     set i [z39.$sno getMarc $no field 710 * a]
187     if {"x$i" != "x"} {
188         insertWithTags $w "Corporate name " marc-pref
189         foreach x $i {
190             insertWithTags $w $x marc-text
191         }
192         $w insert end "\n"
193     }
194 }