#!/bin/sh

# disable filename globbing

 echo Content-type: text/html
 echo
 BASE=`pwd`
 
APPLDIR=$BASE/appl
DATADIR=$BASE/data
PATH=$PATH:$BASE/ihd/bin:.
export PATH APPLDIR DATADIR
Enc=../bolet/Enc1020
bol1=../bolet/bol1
awk -F^ ' 
FILENAME== ARGV[1] { enc[$1]=$2 ; next }

NF >1 { printf $2,enc[$1] ; next }
{ print }
' $Enc $bol1
awk -F^ ' 
FILENAME== ARGV[1] { enc[$1]=$2 ; next }
END {
	x=enc["LineasdeDetalle"]
	Det="../bolet/Detalle"

for (i=1;i<=x;i++)
{
	ss=sprintf("%.2d",i)
	enc["item"ss]=i
	for (j=1;j<7;j++)
	{
		getline < Det
		if(NF==2) printf $2"\n",enc[$1""ss]
		else print
	}
	close(Det)
}

}
' $Enc
