1 #-------------------------------------------------------------
8 my $type = shift || die "parset_format must be called with type!";
9 my $format = shift || die "parse_format must be called with format!";
10 my $row = shift || die "parse_format must be called with row!";
11 my $i = shift || 0; # isis repeatable number
12 my $codepage = shift || die "parse_format must be called with codepage!";
13 if ($type eq "isis") {
14 return parse_iso_format($format,$row,$i,$codepage,'isis_sf');
15 } elsif ($type eq "excel") {
16 return parse_excel_format($format,$row,$i,$codepage);
17 } elsif ($type eq "marc") {
18 return parse_iso_format($format,$row,$i,$codepage,'marc_sf');
22 #-------------------------------------------------------------
24 sub parse_iso_format {
31 my $func = shift || die "need to know which sub-field function to use";
39 if ($format =~ s/^([^\d]+)//) {
49 $tmp = $codepage->convert($tmp) || print STDERR "$1$2 = '$tmp' can't convert";
55 #print STDERR "\n#### $format";
56 # this is EBSCO special to support numeric subfield in
58 if ($format =~ s/^(\d\d\d)#*(\w?)//) {
59 my $tmp = get_sf($row,$1,$2,$i);
61 $display .= $prefix.cnv_cp($tmp);
63 #print STDERR " == $tmp";
66 # this might be our local scpeciality -- fields 10 and 11
67 # (as opposed to 010 and 011) so they are strictly listed
69 } elsif ($format =~ s/^(1[01])//) {
70 my $tmp = get_sf($row,$1,undef,$i);
72 $display .= $prefix.cnv_cp($tmp);
76 } elsif ($format =~ s/^mfn//i) {
77 $display .= $prefix . $row->{mfn};
79 } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
80 $prefix .= $1 if ($display);
81 } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
82 $prefix .= $1 if ($display);
83 } elsif ($format =~ s/^(\d{1,2})//) {
84 $prefix .= $1 if ($display);
86 print STDERR "unparsed format: $format\n";
92 $display .= $prefix if ($display);
94 return ($swish,$display);
97 #-------------------------------------------------------------
99 sub parse_excel_format {
103 my $codepage = shift;
109 if ($format =~ s/^([^A-Z\|]{1,3})//) {
116 while ($format && length($format) > 0) {
117 #print STDERR "\n#### $format #";
118 if ($format =~ s/^\|([A-Z]{1,2})\|//) {
119 #print STDERR "--$1-> $format -[",length($format),"] ";
121 my $tmp = $row->{$1};
123 $tmp = $codepage->convert($tmp) || warn "excel: $1 '$tmp' can't convert";
125 $display .= $prefix . $tmp;
127 #print STDERR " == $tmp";
130 } elsif ($format =~ s/^([^A-Z\|]+)(\|[A-Z]{1,2}\|)/$2/) {
131 $prefix .= $1 if ($display);
133 print STDERR "unparsed format: $format\n";
137 #print STDERR " display: $display swish: $swish [format: $format]";
140 $display .= $prefix if ($display);
142 return ($swish,$display);