#!/usr/bin/perl
#
# print header stuff
#
print "Content-type: text/html", "\n\n";
print "<html>\n";
@bin=('0000','0001','0010','0011',
'0100','0101','0110','0111',
'1000','1001','1010','1011',
'1100','1101','1110','1111');
$preferred="preffered";
print "<table border=\"1\">\n";
print "<tr>\n";
print "<td colspan=\"6\"><center>Packed Decimal Numbers</center></td>";
print "</tr>\n";
print "<tr>\n";
print "<td colspan=\"6\">Digits and signs used to build packed decimal numbers</td>";
print "</tr>\n";
print "<tr>\n";
print "<td rowspan=\"2\">Digit or Sign</td>";
print "<td rowspan=\"2\"><center>Type<br>Digit/Sign</center></td>";
print "<td colspan=\"4\"><center>Value</center></td></tr>";
print "<tr><td>Decimal</td>";
print "<td>Hex</td>";
print "<td>Binary</td>";
print "<td>Octal</td></tr>";
print "</tr>\n";
for ($i=0;$i<=15;$i++) {
print "<tr>\n";
if ($i < 10 ) {
print "<td>$i</td>\n";
print "<td>DIGIT</td>\n";
}
else {
$sign="";
if ($i == 0xa || $i == 0xc || $i == 0xe || $i == 0xf) {
$sign="+";
}
else {
if ($i == 0xd || $i == 11 ) {
$sign="-";
}
else {
$sign="?";
}
}
$best="";
if ($i == 0xc || $i == 0xd ) {
$best=$preferred;
}
else {
$best="";
}
print "<td>$sign $best</td>\n";
print "<td>SIGN</td>\n";
}
print "<td align=\"right\">$i</td>\n";
$x = sprintf("%02X", $i);
$octal = sprintf("%02o", $i);
print "<td>$x</td>\n";
print "<td>$bin[$i]</td>\n";
print "<td>$octal</td>\n";
print "</tr>\n";
}
print "</table>\n";
print "<table border=\"1\">\n";
print "<tr>\n";
print "<td colspan=\"6\"><center>Packed Decimal Numbers</center></td>";
print "</tr>\n";
print "<tr>\n";
print "<td colspan=\"6\">Signs used to build packed decimal numbers</td>";
print "</tr>\n";
print "<tr>\n";
print "<td rowspan=\"2\">Sign</td>";
print "<td colspan=\"4\"><center>Value</center></td></tr>";
print "<tr><td>Decimal</td>";
print "<td>Hex</td>";
print "<td>Binary</td>";
print "<td>Octal</td></tr>";
print "</tr>\n";
for ($i=0;$i<=15;$i++) {
print "<tr>\n";
if ($i < 10 ) {
print "<td>Illegal</td>\n";
}
else {
$sign="";
if ($i == 0xa || $i == 0xc || $i == 0xe || $i == 0xf) {
$sign="+";
}
else {
if ($i == 0xd || $i == 11 ) {
$sign="-";
}
else {
$sign="?";
}
}
$best="";
if ($i == 0xc || $i == 0xd ) {
$best=$preferred;
}
else {
$best="";
}
print "<td>$sign $best</td>\n";
}
print "<td align=\"right\">$i</td>\n";
$x = sprintf("%02X", $i);
$octal = sprintf("%02o", $i);
print "<td>$x</td>\n";
print "<td>$bin[$i]</td>\n";
print "<td>$octal</td>\n";
print "</tr>\n";
}
print "</table>\n";
print "<table border=\"1\">\n";
print "<tr>\n";
print "<td colspan=\"6\"><center>Packed Decimal Numbers</center></td>";
print "</tr>\n";
print "<tr>\n";
print "<td colspan=\"6\">Digits used to build packed decimal numbers</td>";
print "</tr>\n";
print "<tr>\n";
print "<td rowspan=\"2\">Digit</td>";
print "<td colspan=\"4\"><center>Value</center></td></tr>";
print "<tr><td>Decimal</td>";
print "<td>Hex</td>";
print "<td>Binary</td>";
print "<td>Octal</td></tr>";
print "</tr>\n";
for ($i=0;$i<=15;$i++) {
print "<tr>\n";
if ($i < 10 ) {
print "<td>$i</td>\n";
}
else {
$sign="";
if ($i == 0xa || $i == 0xc || $i == 0xe || $i == 0xf) {
$sign="+";
}
else {
if ($i == 0xd || $i == 11 ) {
$sign="-";
}
else {
$sign="?";
}
}
$best="";
if ($i == 0xc || $i == 0xd ) {
$best=$preferred;
}
else {
$best="";
}
print "<td>Illegal</td>\n";
}
print "<td align=\"right\">$i</td>\n";
$x = sprintf("%02X", $i);
$octal = sprintf("%02o", $i);
print "<td>$x</td>\n";
print "<td>$bin[$i]</td>\n";
print "<td>$octal</td>\n";
print "</tr>\n";
}
print "</table>\n";
print "<p>";
print "See also:";
print "<ul>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript\">Mike's Java Script</a> Contains Several ASCII, EBCDIC, tables";
print "<li><a href=\"http://www.geocities.com/mikes_javascript\">Packed Decimal Tables</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">ASCII Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">EBCDIC Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">BCD Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">FIELD DATA Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">FIELDATA Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">Baudot Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">Baudot Figures</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">Baudot Letters</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">Control Character Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">Control Characters</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_table_ascii.html\">Powers of Two</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_cardpunch.html\">Card Punch Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_cardpunch.html\">ASCII Card Punch Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_cardpunch.html\">EBCDIC Card Punch Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_cardpunch.html\">FIELD DATA Card Punch Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_cardpunch.html\">FIELDATA Card Punch Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_morse.html\">Morse Code Characters</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_morse.html\">Morse Code Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_morse.html\">Morse Code to ASCII Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_morse.html\">Morse Code to EBCDIC Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_morse.html\">Morse Code to FIELDATA Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_braille.html\">Braille Characters</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_braille.html\">Braille Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_braille.html\">Braille to ASCII Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_braille.html\">Braille to EBCDIC Table</a>";
print "<li><a href=\"http://www.geocities.com/mikes_javascript/hex_braille.html\">Braille to FIELDATA Table</a>";
print "</ul>";
print "<body background=\"nevada.gif\">\n";
#
#define stuff to grab data entered on form
#
require TripodCGI;
use CGI;
$cgi = new CGI;
#
# get the file name they want to list
#
$name=$cgi->param('name');
#
#
#open the file so we can read it and print it
#
exit;