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