Feature: SUTRS. Setting getSutrs implemented.
[ir-tcl-moved-to-github.git] / formats / raw.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: raw.tcl,v $
7 # Revision 1.4  1995-06-22 13:16:29  adam
8 # Feature: SUTRS. Setting getSutrs implemented.
9 # Work on display formats.
10 #
11 # Revision 1.3  1995/06/14  12:16:42  adam
12 # Minor presentation format changes.
13 #
14 # Revision 1.2  1995/06/12  15:18:10  adam
15 # Work on presentation formats. These are used in the main window as well
16 # as popup windows.
17 #
18 #
19 proc display-raw {sno no w hflag} {
20     if {$hflag} {
21         insertWithTags $w "\n$no\n" {}
22     } else {
23         $w delete 0.0 end
24     }
25     set type [z39.$sno type $no]
26     if {$type == "SD"} {
27         set err [lindex [z39.$sno diag $no] 1]
28         set add [lindex [z39.$sno diag $no] 2]
29         if {$add != {}} {
30             set add " :${add}"
31         }
32         insertWithTags $w "Error ${err}${add}\n" marc-id
33         return
34     }
35     if {$type != "DB"} {
36         return
37     }
38     set rtype [z39.$sno recordType $no]
39     if {$rtype == "SUTRS"} {
40         insertWithTags $w [join [z39.$sno getSutrs $no]] {}
41         $w insert end "\n"
42         return
43     } 
44     if {[catch {set r [z39.$sno getMarc $no list * * *]}]} {
45         insertWithTags $w "Unknown record type: $rtype\n" marc-id
46         return
47     }
48     foreach line $r {
49         set tag [lindex $line 0]
50         set indicator [lindex $line 1]
51         set fields [lindex $line 2]
52         
53         if {$indicator != ""} {
54             insertWithTags $w "$tag $indicator" marc-tag
55         } else {
56             insertWithTags $w "$tag    " marc-tag
57         }
58         foreach field $fields {
59             set id [lindex $field 0]
60             set data [lindex $field 1]
61             if {$id != ""} {
62                 insertWithTags $w " $id " marc-id
63             }
64             insertWithTags $w $data {}
65         }
66         $w insert end "\n"
67     }
68 }
69