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