#!/bin/nawk -f
#
# purpose: Script to parse an fdesign .c file and recast the 
# create-form functions found there as methods of the appropriate Forms class.
#

BEGIN {
	print "";
	print \
	"// --- InitForm declarations for the Forms classes ---------------------------";
	print "";
	print "";
}
(insub == 1) {
#  print $1 " // " form "->fdui";

	if ($1 == "return")
		; # omit return
	else if (substr($1, 1, 3) == "FD_")
		; # omit declaration of fdui variable.
	else if ($1 == "fdui->" form "->fdui")
	  ; # omit final assignment of fdui
	else if (substr($1, 1, 6) == "fdui->")
	{
		# omit use of fdui variable.
		$1 = substr($1, 7, length($1) - 6);
		if ($1 == form)
			$1 = "form";
		print "    " $0;
	}
	else	
		print $0;
}
/^FD_/ {
	form = substr($1, 4, length($1) - 3);
    name = form "Form";
	print "void " name "::InitForm()"; 
    insub = 1;
}
$0 == "}" {
	insub = 0;
	print "";
};
