#altpress.cgi
#Change pressure to millibars and height to meters
if ($alt{press} =~ /(\d+)\.?(\d+)|^\d+?/) {
if ($alt{inormb} =~ millibars) {
$press = $alt{press};
} else {
$press = $alt{press} * 33.8639;
}
} else {
print "An illegal character was entered.\n";
die
}
if ($alt{height} =~ /(\d+)\.?(\d+)|^\d+$/) {
if ($alt{ftorm} =~ meters) {
$height = $alt{height};
} else {
$height = $alt{height} * .3048;
}
} else {
print "An illegal character was entered.\n";
die
}
#Do some math
$F1 = ((1013.25**0.190284)*0.0065)/288;
$F2 = $height/($press - 0.3)**0.190284;
$F3 = 1/0.190284;
$F = (1 + ($F1 * $F2))**$F3;
$as = ($press - 0.3)* $F;
$as1 = $as * 0.0295300;
#Make some pretty output
$~ = AT1;
write;
format AT1 =
With a station pressure of @###.## @<<<<<<<<<<<<<<<<< and a station
$alt{press} $alt{inormb}
elevation of @####.# @<<<<<<:
$alt{height} $alt{ftorm}
You get an altimeter setting of @#.## inches of Mercury or @###.# Millibars. $as1 $as . print "
Please note, if you are pilot, you should not use the Weather Calculator for any kind of flight planning. The Weather Calculator is for general information and entertainment purposes only.
";