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