5 proc flushfields {f tag} {
8 if {[string compare $tag {}] == 0} {
11 puts $f "elm $tag $tag -"
12 foreach sub [array names specs] {
13 puts -nonewline $f "elm $tag/$sub ${tag}_${sub} "
15 foreach spec [lsort -unique $specs($sub)] {
16 puts -nonewline $f "$sep[lindex $spec 0]:[lindex $spec 1]"
24 set absfile [open danbib.abs w]
27 puts $absfile "name danbib"
29 puts $absfile "attset danbib.att"
31 while {[gets stdin line] >= 0} {
32 set ch [string index $line 0]
33 if {[string compare $ch \#] && [scan $line "%s %s %s %s %s %s %s %s %s" tag class fieldid marcid prefixid subfields str cats format] > 6} {
35 if {[string compare $prevtag $tag]} {
36 flushfields $absfile $prevtag
39 for {set i 0} {$i < [string length $subfields]} {incr i} {
40 set subchar [string index $subfields $i]
41 if {[string compare $fieldid {-}] != 0} {
44 if {![info exists attr($prefixid)]} {
45 set attr($prefixid) $attrseq
48 lappend specs($subchar) [list $prefixid [string tolower $class]]
52 if {[string compare $prevtag $tag]} {
53 flushfields $absfile $prevtag
56 set attfile [open danbib.att w]
57 puts $attfile "name danbib"
58 puts $attfile "reference Bib-1"
60 foreach a [array names attr] {
62 puts $attfile "att $attr($a) $a"