#--------------------------------
#
sub parsecheck {
($frmt, $start, $end, $ra, $dec, $freeform) = @_;
@MESSAGE = ('
Please enter RA as hh:mm:ss.ss',
'Please enter DEC as (-)dd:mm:ss.ss',
'Please enter start date as mm/dd/yyyy',
'Please enter end date as mm/dd/yyyy',
);
# parse
if ($frmt eq 'fixed') {
if ($ra && $dec && $start) {
$end = $start if ($end eq '');
}
push @starts, $start;
push @ends, $end;
push @ras, $ra;
push @decs, $dec;
} elsif ($frmt eq 'free') {
# extract the "lines" from the input
@lines = split /\n/, $freeform;
# loop on the lines and see what we got
foreach $i (0 .. $#lines) {
($ra,$dec,$start,$end) = split / /, &trim($lines[$i]), 4;
if ($ra && $dec && $start) {
$end = $start if ($end eq '');
}
push @starts, $start;
push @ends, $end;
push @ras, $ra;
push @decs, $dec;
}
} else {
$errmsg = '';
return ('Please complete the form and submit using the Calculate button.');
}
# look for any error and quit at the first sight
foreach $i (0 .. $#starts) {
$errmsg = '';
$errmsg = $errmsg.$MESSAGE[0] if ($ras[$i] !~ /[0-9]+:[0-9]+/);
$errmsg = $errmsg.$MESSAGE[1] if ($decs[$i] !~ /[0-9]+:[0-9]+/);
$errmsg = $errmsg.$MESSAGE[2] if ($starts[$i] !~ /[0-9]{2}\/[0-9]{2}\/[0-9]{4}/);
$errmsg = $errmsg.$MESSAGE[3] if ($ends[$i] !~ /[0-9]{2}\/[0-9]{2}\/[0-9]{4}/);
if ($errmsg) {
$errmsg = "
Warning!$errmsg
Please use your browser'
s back button to revise your input and then submit your request again.
For assistance please contact: help\@stsci.edu.";
last;
}
}
return ($errmsg, \@starts, \@ends, \@ras, \@decs);
}