awk -F= 'BEGIN { 
T["00"]="REGISTRO"
T["01"]="CóDIGO                   "
T["02"]="DESCRIPCIóN              "
T["03"]="UNIDAD"
T["04"]="OBSERVACIONES"
T["05"]="STATUS"
T["06"]="MM"
T["07"]="MARCA"
T["08"]="COLOR"
T["09"]="COSTO"
T["10"]="OBSERVACIONES"
	printf "%s^",T["00"]
}
substr($1,1,6)=="basesD" && substr($1,1,8)!="basesD00"  { next }
$2!="" && substr($1,1,6)=="basesH" {
        if(substr($1,length($1)-1)!="00")
        {
                x=substr($1,length($1)-1)
                printf "%s^",T[x]
        }
}
$2!="" && substr($1,1,6)=="basesD" {
                printf "%s^",T[NR-1]
}
END {
	print ""
} ' $1 |
 awk -F"^" ' BEGIN {ttop("Consulta de Datos en BASES");bgcolor="#FFFFFF"}
NR==1 { for (i=1; i<NF; i++) labels($i)
print "</tr>"
next
}
{ for (i=1; i<NF; i++)if (i==1) boton($i)
else label($i)
print "</tr>"
if (NR%2==0 ) bgcolor="#E1E1E1"
else bgcolor="#FFFFFF"
}
END { foot() } 
function boton(value)
{
	print "<td bgcolor=\"#E1E1E1\">"
printf "<p><input type=\"submit\" style=\"width: 120\" value=\"%s\" name=\"T02\"></p>\n",value
print "</td>"
}
function label(value)
{
printf "<td bgcolor=\"%s\">",bgcolor
printf "<p align=\"center\"><font face=\"Arial\" size=\"3\">&nbsp;%s&nbsp;</font></p>\n",value
print "</td>"
}
function labels(value)
{
print "<td bordercolor=\"#C0C0C0\" bgcolor=\"#003399\" align=\"center\">"
printf "<p align=\"center\"><b><font color=\"#FFFFFF\">%s</font></b></p>\n",value
print "</td>"
}
function ttop(value)
{
print "<html>"
print "<head>"
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
print "<meta name=\"GENERATOR\" content=\"Inhedo 4gt 1.0\">"
print "<meta name=\"ProgId\" content=\"Inhedo Form Generator\">"
printf "<title>%s</title>\n",value
print "</head>"
print "<center>"
print "<body bgcolor=\"#D0D0DF\">"
print "<p align=\"center\"><img border=\"0\" src=\"../logol.png\" width=\"200\" height=\"97\"></p>"
printf "<H1>BASES</H1>\n"
print "<form method=\"post\" action=\"../cgi-bin/basesbsc.cgi\" name=billform>"
print "<center>"
print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#999999\" height=\"50\">"
printf "<input type=\"hidden\" value=\"Query\" name=\"B1\">\n"
print "<tr>"
print "</center>"
}
function foot()
{
print "</table>"
print "</center>"
print "</form>"
print "<b>"NR -1 " Registros encontrados</b>"
print "</body>"
print "</html>"
} ' - $2
awk ' BEGIN {
print "</body>"
print "</form>"
print "<form method=\"GET\" action=\"../bases.htm\">"
printf "<p align=\"center\"><input type=\"submit\" value=\"Continuar\" name=\"B1\" style=\"width: 200; height: 50; font-weight: bold; font-size: 18pt\"></p>\n"
print "</form>"
print "</body>"
print "</html>"
exit } ' - $2
