{
BASE=`pwd`
APPLDIR=$BASE/appl
DATADIR=$BASE/data
PATH=$PATH:$BASE/ihd/bin:.
export PATH APPLDIR DATADIR TZ
$APPLDIR/sh/categoriasmprimas $1 |
awk -F"^" ' BEGIN {
NH=5
L=17
}
#/Misc0/ {
 #mis++
 #xx=index($0,"Misc0")
 #print
 #getline
 #if(mis==1) print "'"$misc1"'"
 #else print "'"$misc2"'"
#}
function trail(txt) { while (substr(txt,length(txt),1)==" ") txt=substr(txt,1,length(txt)-1); return (txt) }
FILENAME==ARGV[1] && NR==1 { for (i=1;i<=NH;i++)
{
	indx=sprintf("categoriasmprimasH%.2d",i-1)
	reg[indx]=trail($i)
}
}
FILENAME==ARGV[1] {
for (i=NH+1;i<NF;i++)
{
	indx=sprintf("categoriasmprimasD%.2d%.2d",NR-1,i-1-NH)
	doc[indx]=trail($i)
}
next
}
/categoriasmprimasH/ {
xx=index($0,"categoriasmprimasH")
indx=substr($0,xx,L+3)
if(index($0,"input")) printf "%svalue=\"%s\" %s\n",substr($0,1,xx-7), reg[indx],substr($0,xx-6) 
if(index($0,"select"))
{
	print
	split(reg[indx],r,"|")
	while ($0!="</select>")
	{
		getline
		if (index($0,r[1]"\">") && r[1]!="")
		{
			xx=index($0,">")
			print substr($0,1,xx-1)" selected"substr($0,xx)
		}
		else print
	}
}
if(index($0,"textarea"))
{
	print
	print reg[indx]
}
next
}
/categoriasmprimasD/ {
xx=index($0,"categoriasmprimasD")
indx=substr($0,xx,L+3)
rr=split($0,r,">")
for(i=0;i<rr-1;i++) printf "%s value=\"%s\">",r[i+1],doc[indx""sprintf("%.2d",i)]
		print ""
next
}
{ print }

' - ../categoriasmprimas.html
} 2>error/categoriasmprimasget.err
cat error/categoriasmprimasget.err
