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