 BASE=`pwd`
APPLDIR=$BASE/appl
DATADIR=$BASE/data
PATH=$PATH:$BASE/ihd/bin:.
export PATH APPLDIR DATADIR
forms=./tmp/forms
./appl/sh/forms >$forms

# |  1 H00 formid  005 000   0 | 2 H01 identi  040 000   5 | 3 H02 typesf  001 057  45 | 4 H03 linesd  002 001  46 | 5 H04 pagesd  002 001  48 |
# |  6 H05 perio1  035 000  50 | 7 H06 perio2  035 000  85 | 8 H07 number  007 001 120 | 9 H08 javasc  080 000 127 |10 H09 hflags  080 000 207 |
# | 11 H10 extcom  200 010 287 |

# | 12 D00 hea_do  1   00 | 13 D01 datoid  06  00 | 14 D02 descri  25  00 | 15 D03 typesd  02  55 | 16 D04 length  3   01 |
# | 17 D05 sindou  02  01 | 18 D06 nforms  5   56 | 19 D07 lfield  6   00 | 20 D08 displa  02  01 | 21 D09 lendis  03  01 |
# | 22 D10 funct0  40  00 |
newform=./tmp/newform
ihmq newform h00"^" h01"^" h02"^" h03"^" h04"^" h05"^" h06"^" h07"^" h08"^" h09"^" h10"^" h11"^" h12"^" d00"^" d01"^" d02"^" d03"^" d04"^" d05"^" d06"^" d07"^" d08"^" d09"^" d10"^" d11"^" d12"^" d13 > $newform

# |  1 H00 registe 004 015   0 | 2 H01 formID  020 000   4 | 3 H02 descrip 040 000  24 | 4 H03 formtyp 001 051  64 | 5 H04 lines   002 001  65 |
# |  6 H05 pages   002 001  67 | 7 H06 creatio 010 008  69 | 8 H07 periods 256 000  79 | 9 H08 javascr 256 000 335 |10 H09 hiddenf 256 000 591 |
# | 11 H10 autonum 001 017 847 |12 H11 extrasb 999 011 848 |13 H12 initial 007 001 1847 |

# | 14 D00 hd      001 00 | 15 D01 dataid  020 00 | 16 D02 descrip 040 00 | 17 D03 placeho 040 00 | 18 D04 span    003 01 |
# | 19 D05 datatyp 002 52 | 20 D06 length  004 01 | 21 D07 newline 001 01 | 22 D08 linkfor 004 53 | 23 D09 linkfie 020 02 |
# | 24 D10 display 003 01 | 25 D11 display 004 01 | 26 D12 functio 256 00 | 27 D13 require 001 17 |
#

awk -F^ ' BEGIN {
f["01"]="02"
f["02"]="03"
f["03"]="04"
f["04"]="05"
f["05"]="06"
f["07"]="08"
f["08"]="13"
f["09"]="09"
f["10"]="10"
f["11"]="12"
f["12"]="14"
f["13"]="15"
f["14"]="16"
f["15"]="19"
f["16"]="20"
f["18"]="22"
f["19"]="23"
f["20"]="24"
f["21"]="25"
f["22"]="26"
z=0
}
"'"$1"'"!=$1 { next }
z==0 {
for (i=1;i<12;i++)
{
	reg=sprintf("%.2d",i)
	if(f[reg]!="") printf "H%.2d%s\n",f[reg]-1,$i
}
}
{
	for (i=12;i<23;i++) 
	{
		reg=sprintf("%.2d",i)
		if(f[reg]!="") printf "D%.2d%.2d%s\n",z,f[reg]-14,$i
	}
	z++
}
' $forms >/tmp/$1
./ihd/bin/ihmu newform /tmp/$1 -N1
