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_isis_format($format,$row,$i,$codepage);
15 } elsif ($type eq "excel") {
16 return parse_excel_format($format,$row,$i,$codepage);
20 #-------------------------------------------------------------
22 sub parse_isis_format {
34 if ($format =~ s/^([^\d]+)//) {
42 #print STDERR "\n#### $format";
43 if ($format =~ s/^(\d\d\d)(\w?)//) {
44 my $tmp = isis_sf($row,$1,$2,$i);
47 $tmp = $codepage->convert($tmp) || warn "row: ",$row->{mfn},", $1$2 '$tmp' can't convert";
49 $display .= $prefix . $tmp;
51 #print STDERR " == $tmp";
54 # this might be our local scpeciality -- fields 10 and 11
55 # (as opposed to 010 and 011) so they are strictly listed
57 } elsif ($format =~ s/^(1[01])//) {
58 my $tmp = isis_sf($row,$1,undef,$i);
61 $tmp = $codepage->convert($tmp) || warn "row: ",$row->{mfn},", $1$2 '$tmp' can't convert";
63 $display .= $prefix . $tmp;
67 } elsif ($format =~ s/^mfn//i) {
68 $display .= $prefix . $row->{mfn};
70 } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
71 $prefix .= $1 if ($display);
72 } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
73 $prefix .= $1 if ($display);
74 } elsif ($format =~ s/^(\d{1,2})//) {
75 $prefix .= $1 if ($display);
77 print STDERR "unparsed format: $format\n";
83 $display .= $prefix if ($display);
85 return ($swish,$display);
88 #-------------------------------------------------------------
90 sub parse_excel_format {
100 if ($format =~ s/^([^A-Z\|]{1,3})//) {
107 while ($format && length($format) > 0) {
108 #print STDERR "\n#### $format #";
109 if ($format =~ s/^\|([A-Z]{1,2})\|//) {
110 #print STDERR "--$1-> $format -[",length($format),"] ";
112 my $tmp = $row->{$1};
114 $tmp = $codepage->convert($tmp) || warn "excel: $1 '$tmp' can't convert";
116 $display .= $prefix . $tmp;
118 #print STDERR " == $tmp";
121 } elsif ($format =~ s/^([^A-Z\|]+)(\|[A-Z]{1,2}\|)/$2/) {
122 $prefix .= $1 if ($display);
124 print STDERR "unparsed format: $format\n";
128 #print STDERR " display: $display swish: $swish [format: $format]";
131 $display .= $prefix if ($display);
133 return ($swish,$display);