awk -F= 'BEGIN {
T["00"]="REGISTRO"
T["01"]="FORM ID"
T["02"]="FORM NAME"
T["03"]="FORM TYPE"
T["04"]="LINES"
T["05"]="PAGES"
T["06"]="CREATION DATE"
T["07"]="PERIODS"
T["08"]="JAVASCRIPT"
T["09"]="HIDDEN FLAGS"
T["10"]="AUTONUMBER"
T["11"]="EXTRA SUBMIT BAR"
T["12"]="INITIAL REGISTER"
T["13"]="HD"
T["14"]="DATA ID"
T["15"]="DESCRIPTION"
T["16"]="PLACEHOLDER"
T["17"]="SPN"
T["18"]="DATA TYPE"
T["19"]="LEN"
T["20"]="NL"
T["21"]="LFORM"
T["22"]="LFIELD"
T["23"]="DSP"
T["24"]="LND"
T["25"]="FUNCTONS"
T["26"]="RQ"
printf "%s^",T["00"]
NH=13
}
!/newformH/ && !/newformD00/  { next }
$2!="" && /newformH/ {
        if(substr($1,length($1)-1)!="00")
        {
                x=substr($1,length($1)-1)
                printf "%s^",T[x]
        }
}
$2!="" && /newformD/ {
                x=substr($1,length($1)-1,2)
                printf "%s^",T[x+NH]
}
END {
	print ""
} ' $1 |
awk -F^ ' BEGIN {
ttop("B&uacute;squeda en Forms 2022 V2.0");bgcolor="#FFFFFF"}
{
for (i=1;i<NF;i++ ) printf "%s^",trail($i)>"tmp/'"$1"'"
print "">"tmp/'"$1"'"
}
NR==1 { print "<tr>";labels("##"); for (i=1; i<NF; i++) labels(trail($i))
print "</tr>"
next
}
function trail(txt) { while (substr(txt,length(txt),1)==" ") txt=substr(txt,1,length(txt)-1); return (txt) }
{
print "<tr>";label(NR-1,"")
for (i=1; i<NF; i++)if (i==1) boton($i)
else label($i,"")
print "</tr>"
}
END { foot() } 
function boton(value)
{
	print "<td>"
	printf "<input type=\"submit\" style=\"width: 80; background-color: #ddd;\" value=\"%s\" name=\"T02\">\n",value
	print "</td>"
}
function label(value,sty)
{
        if(value+0 || trail(value)=="0") align=" align=\"right\""
	else align=""
printf "<td%s %s>",align,sty
printf "&nbsp;%s&nbsp;\n",trail(value)
print "</td>"
}
function labels(value)
{
print "<th>"
printf "&nbsp;%s&nbsp;\n",trail(value)
print "</th>"
}
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\">"
print "<link rel=\"stylesheet\" href=\"../css/list.css\">"
printf "<title>%s</title>\n",value
print "</head>"
print "<center>"
print "<body>"
print "<tr><img border=\"0\" src=\"../logol.png\" width=\"200\" height=\"97\" style=\"background:#003399;border:solid 1px #FFFF00;\"></tr>"
printf "<H2>B&uacute;squeda en Forms 2022 V2.0</H2>\n"
print "<form method=\"post\" action=\"../cgi-bin/newformbsc.cgi\" name=billform>"
print "<table id=\"customers\">"
printf "<input type=\"hidden\" value=\"Query\" name=\"B1\">\n"
print "<tr>"
print "</center>"
}
function foot()
{
print "</table>"
print "<b>"NR -1 " Registros</b>"
print "</center>"
print "</form>"
print "</body>"
print "</html>"
} ' - $2
awk ' BEGIN {
t1="'"$1"'"
print "</body>"
print "</form>"
print "<form method=\"post\" action=\"../cgi-bin/exc.cgi\">"
print "<input type=\"hidden\" value=\"newform\" name=\"B2\">"
printf "<p align=\"center\"><input type=\"submit\" value=\"Continuar\" name=\"B1\" style=\"width: 100; height: 20; font-weight: bold; font-size: 10pt\">\n"
printf "<input type=\"submit\" value=\"Excel\" name=\"B1\" style=\"width: 100; height: 20; font-weight: bold; font-size: 10pt\"></p>\n"
print "</form>"
print "</body>"
print "</html>"
exit } ' - $2
