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