%args>
$quri
$qa
$routestring => '';
%args>
<%perl>
my @archipelagoes;
my @islandids;
my %islandid2;
%perl>
%#---------- textbox, user enters route as string ----------
% if (!$qa->{Dropdowns}) {
Specify route
<%perl>
#========== result computations ==========
my $results_head;
$results_head= sub {
print "Results
\n";
$results_head= sub { };
};
#---------- result computation - textstring ----------
if (!$qa->{Dropdowns}) {
if (length $routestring) {
$results_head->();
my $rsr= $m->comp('routetextstring',
ocean => $qa->{Ocean},
string => $routestring,
format => 'return'
);
if (length $rsr->{Error}) {
print encode_entities($rsr->{Error});
} else {
foreach my $entry (@{ $rsr->{Results} }) {
push @archipelagoes,
defined $entry->[1] ? undef : $entry->[0];
push @islandids, $entry->[1];
}
}
}
} else { #---------- results - dropdowns ----------
my $argorundef= sub {
my ($dd,$base) = @_;
my $thing= $ARGS{"${base}${dd}"};
$thing= undef if defined $thing and $thing eq 'none';
return $thing;
};
for my $dd (0..$qa->{Dropdowns}-1) {
my $arch= $argorundef->($dd,'archipelago');
my $island= $argorundef->($dd,'islandid');
next unless defined $arch or defined $island;
if (defined $island and defined $arch) {
my $ii= $islandid2{$island};
my $iarch= $ii->{Arch};
if ($iarch ne $arch) {
$results_head->();
%perl>
Specified archipelago <% $arch %> but
island <% $ii->{Name} %>
which is in <% $iarch %>; using the island.
<%perl>
}
$arch= undef;
}
push @archipelagoes, $arch;
push @islandids, $island;
}
}#---------- result processing, common stuff
%perl>
% if (@islandids) {
% $results_head->();
<& routetrade, islandids => \@islandids, archipelagoes => \@archipelagoes &>
% }