1 |
#------------------------------------------------------------- |
#------------------------------------------------------------- |
2 |
# |
# |
3 |
# parse_format('format',$isis_row); |
# parse_format(...) |
4 |
# |
# |
5 |
|
|
|
use isis_sf; |
|
6 |
|
|
7 |
sub parse_format { |
sub parse_format { |
8 |
|
my $type = shift || die "parset_format must be called with type!"; |
9 |
my $format = shift || die "parse_format must be called with format!"; |
my $format = shift || die "parse_format must be called with format!"; |
10 |
my $row = shift || die "parse_format must be called with row!"; |
my $row = shift || die "parse_format must be called with row!"; |
11 |
my $i = shift || 0; # isis repeatable number |
my $i = shift || 0; # isis repeatable number |
12 |
my $codepage = shift || die "parse_format must be called with codepage!"; |
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); |
17 |
|
} |
18 |
|
} |
19 |
|
|
20 |
|
#------------------------------------------------------------- |
21 |
|
|
22 |
|
sub parse_isis_format { |
23 |
|
use isis_sf; |
24 |
|
|
25 |
|
my $format = shift; |
26 |
|
my $row = shift; |
27 |
|
my $i = shift; |
28 |
|
my $codepage = shift; |
29 |
|
|
30 |
my $out; |
my $out; |
31 |
my $out_swish; |
my $out_swish; |
82 |
} |
} |
83 |
|
|
84 |
#------------------------------------------------------------- |
#------------------------------------------------------------- |
85 |
|
|
86 |
|
sub parse_excel_format { |
87 |
|
my $format = shift; |
88 |
|
my $row = shift; |
89 |
|
my $i = shift; |
90 |
|
my $codepage = shift; |
91 |
|
|
92 |
|
my $out; |
93 |
|
my $out_swish; |
94 |
|
|
95 |
|
my $prefix = ""; |
96 |
|
if ($format =~ s/^([^A-Z\|]{1,3})//) { |
97 |
|
$prefix = $1; |
98 |
|
} |
99 |
|
|
100 |
|
my $display; |
101 |
|
my $swish; |
102 |
|
|
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),"] "; |
107 |
|
if ($row->{$1}) { |
108 |
|
my $tmp = $row->{$1}; |
109 |
|
$tmp = $codepage->convert($tmp) if ($codepage); |
110 |
|
$display .= $prefix . $tmp; |
111 |
|
$swish .= $tmp." "; |
112 |
|
#print STDERR " == $tmp"; |
113 |
|
} |
114 |
|
$prefix = ""; |
115 |
|
} elsif ($format =~ s/^([^A-Z\|]+)(\|[A-Z]{1,2}\|)/$2/) { |
116 |
|
$prefix .= $1 if ($display); |
117 |
|
} else { |
118 |
|
print STDERR "unparsed format: $format\n"; |
119 |
|
$prefix .= $format; |
120 |
|
$format = ""; |
121 |
|
} |
122 |
|
#print STDERR " display: $display swish: $swish [format: $format]"; |
123 |
|
} |
124 |
|
# add suffix |
125 |
|
$display .= $prefix if ($display); |
126 |
|
|
127 |
|
return ($swish,$display); |
128 |
|
} |
129 |
|
|
130 |
1; |
1; |