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 $isis_tmp = isis_sf($row,$1,$2,$i);
46 $isis_tmp = $codepage->convert($isis_tmp) if ($codepage);
47 $display .= $prefix . $isis_tmp;
48 $swish .= $isis_tmp." ";
49 #print STDERR " == $isis_tmp";
52 # this might be our local scpeciality -- fields 10 and 11
53 # (as opposed to 010 and 011) so they are strictly listed
55 } elsif ($format =~ s/^(1[01])//) {
56 my $isis_tmp = isis_sf($row,$1,undef,$i);
58 $isis_tmp = $codepage->convert($isis_tmp) if ($codepage);
59 $display .= $prefix . $isis_tmp;
60 $swish .= $isis_tmp." ";
63 } elsif ($format =~ s/^mfn//i) {
64 $display .= $prefix . $row->{mfn};
66 } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
67 $prefix .= $1 if ($display);
68 } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
69 $prefix .= $1 if ($display);
70 } elsif ($format =~ s/^(\d{1,2})//) {
71 $prefix .= $1 if ($display);
73 print STDERR "unparsed format: $format\n";
79 $display .= $prefix if ($display);
81 return ($swish,$display);
84 #-------------------------------------------------------------
86 sub parse_excel_format {
96 if ($format =~ s/^([^A-Z\|]{1,3})//) {
103 while ($format && length($format) > 0) {
104 #print STDERR "\n#### $format #";
105 if ($format =~ s/^\|([A-Z]{1,2})\|//) {
106 #print STDERR "--$1-> $format -[",length($format),"] ";
108 my $tmp = $row->{$1};
109 $tmp = $codepage->convert($tmp) if ($codepage);
110 $display .= $prefix . $tmp;
112 #print STDERR " == $tmp";
115 } elsif ($format =~ s/^([^A-Z\|]+)(\|[A-Z]{1,2}\|)/$2/) {
116 $prefix .= $1 if ($display);
118 print STDERR "unparsed format: $format\n";
122 #print STDERR " display: $display swish: $swish [format: $format]";
125 $display .= $prefix if ($display);
127 return ($swish,$display);