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