BEGIN { mm=0; f=0; d=0; t=0; MAXF=0;
        for(FNUM=0;FNUM<100;FNUM++) {
            FIELD[FNUM]="";  FLEN[FNUM]=0; FPOS[FNUM]=0; FLIN[FNUM]=0;
            PROMPT[FNUM]=""; PPOS[FNUM]=0; PLIN[FNUM]=0; PLEN[FNUM]=0 }
       } 


NF==4 && $3=="master" && $4=="information" { m=1; next }

m==1 { n=split($0,a,"\t"); FORM="w_" a[4]; m=0; next }  

NF==4 && $3=="field" && $4=="information" { f=1; next }

NF==4 && $3=="group" && $4=="information" { f=0; next }

f==1 { n=split($0,a,"\t"); FNUM=a[3]; if(FNUM>MAXF) { MAXF=FNUM };
       if(a[5]==4){ FIELD[FNUM]=a[4]; FLEN[FNUM]=a[9]};
       gsub("\"","",a[16]); PROMPT[FNUM]=a[16]; PPOS[FNUM]=a[17]; 
       PLIN[FNUM]=a[18]; PLEN[FNUM]=a[19] }

NF==4 && $3=="menubar" && $4=="information" { t=1; next }

t==1 { n=split($0,a,"\t"); gsub("\"","",a[5]); TITLE=a[5]; t=0; next } 

NF==4 && $3=="data" && $4=="information" { d=1; next }

NF==4 && $3=="parameter" && $4=="information" { d=0; next }

d==1 { n=split($0,a,"\t"); FNUM=a[3]; if(FNUM>MAXF) { MAXF=FNUM };
       if(a[4]=="1") { FPOS[FNUM]=a[10]; FLIN[FNUM]=a[11] } }
          
          
END { 
for(FNUM=1;FNUM<=MAXF;FNUM++) {
    if(PLEN[FNUM]!=0) { if(PPOS[FNUM]=="" || PLIN[FNUM]=="") { PLEN[FNUM]=0 } };
    if(FLEN[FNUM]!=0) { if(FPOS[FNUM]=="" || FLIN[FNUM]=="") { FLEN[FNUM]=0 } }
  };
  
print "$PBExportHeader$" FORM ".srw";
print "forward";
print "global type " FORM " from window";
print "end type";
print "type cb_exit from commandbutton within " FORM;
print "end type";
for(FNUM=1;FNUM<=MAXF;FNUM++) {
    if(PLEN[FNUM]!=0) { 
        print "type st_" FNUM " from statictext within " FORM
        print "end type" };
    if(FLEN[FNUM]!=0) { 
        print "type " FIELD[FNUM] " from singlelineedit within " FORM
        print "end type" }
  };
print "type cb_save from commandbutton within " FORM;
print "end type";
print "type cb_clear from commandbutton within " FORM;
print "end type";
print "type cb_delete from commandbutton within " FORM;
print "end type";

print "end forward";
print "";

print "global type " FORM " from window";
print "integer width = 3685";
print "integer height = 1704";
print "boolean titlebar = true";
print "string title = \"" TITLE "\"";
print "boolean controlmenu = true";
print "boolean minbox = true";
print "boolean maxbox = true";
print "boolean resizable = true";
print "windowstate windowstate = maximized!";
print "long backcolor = 67108864";
print "cb_exit cb_exit";
for(FNUM=1;FNUM<=MAXF;FNUM++) {
    if(PLEN[FNUM]!=0) { print "st_" FNUM " st_" FNUM };
    if(FLEN[FNUM]!=0) { print FIELD[FNUM] " " FIELD[FNUM] }
  };
print "cb_save cb_save";  
print "cb_clear cb_clear";  
print "cb_delete cb_delete";  
print "end type";
print "global " FORM " " FORM;
print "";

print "on " FORM ".create";
print "this.cb_exit=create cb_exit";
for(FNUM=1;FNUM<=MAXF;FNUM++) {
    if(PLEN[FNUM]!=0) { print "this.st_" FNUM "=create st_" FNUM };
    if(FLEN[FNUM]!=0) { print "this." FIELD[FNUM] "=create " FIELD[FNUM] }
  };
print "this.cb_save=create cb_save";  
print "this.cb_clear=create cb_clear";
print "this.cb_delete=create cb_delete";
print"this.Control[]={this.cb_exit,&"; 
for(FNUM=1;FNUM<=MAXF;FNUM++) {
    if(PLEN[FNUM]!=0) { print "this.st_" FNUM ",&" };
    if(FLEN[FNUM]!=0) { print "this." FIELD[FNUM] ",&" }
  }; 
print "this.cb_save,&";
print "this.cb_clear,&";
print "this.cb_delete}";
print "end on";
print "";

print "on " FORM ".destroy";
print "destroy(this.cb_exit)";
for(FNUM=1;FNUM<=MAXF;FNUM++) {
    if(PLEN[FNUM]!=0) { print "destroy(this.st_" FNUM ")" };
    if(FLEN[FNUM]!=0) { print "destroy(this." FIELD[FNUM] ")" }
  };  
print "destroy(this.cb_save)";
print "destroy(this.cb_clear)";
print "destroy(this.cb_delete)";
print "end on";
print "";

print "event open;uo_resize n_resize";
print "n_resize.f_winsize(this, true)";
print "end event";
print "";

print "type cb_exit from commandbutton within " FORM;
print "integer x = 3154";
print "integer y = 324";
print "integer width = 402";
print "integer height = 112";
print "integer taborder = 250";
print "integer textsize = -8";
print "integer weight = 700";
print "fontcharset fontcharset = ansi!";
print "fontpitch fontpitch = variable!";
print "fontfamily fontfamily = swiss!";
print "string facename = \"Arial\"";
print "string text = \"Exit\"";
print "end type";
print "";
print "event clicked;// Close parent window";
print "Close(Parent)";
print "end event";
print "";
for(FNUM=1;FNUM<=MAXF;FNUM++) {
    if(PLEN[FNUM]!=0) { 
        print "type st_" FNUM " from statictext within " FORM;
        print "integer x = " 30*PPOS[FNUM];
        print "integer y = " 100*PLIN[FNUM];
        print "integer width = " 30*(PLEN[FNUM]+1);
        print "integer height = 64";
        print "integer textsize = -8";
        print "integer weight = 700";
        print "fontcharset fontcharset = ansi!";
        print "fontpitch fontpitch = variable!";
        print "fontfamily fontfamily = swiss!";
        print "string facename = \"Arial\"";
        print "long textcolor = 33554432";
        print "long backcolor = 67108864";
        print "string text = \"" PROMPT[FNUM] "\"";
        print "boolean focusrectangle = false";
        print "end type";
        print "";
    };
    if(FLEN[FNUM]!=0) {
        print "type " FIELD[FNUM] " from singlelineedit within " FORM;
        print "integer x = " 30*FPOS[FNUM];
        print "integer y = " 100*FLIN[FNUM];
        print "integer width = " 45*(FLEN[FNUM]+1);
        print "integer height = 88";
        print "integer taborder = 10";
        print "integer textsize = -8";
        print "integer weight = 400";
        print "fontcharset fontcharset = ansi!";
        print "fontpitch fontpitch = variable!";
        print "fontfamily fontfamily = swiss!";
        print "string facename = \"Arial\"";
        print "long textcolor = 33554432";
        print "borderstyle borderstyle = stylelowered!";
        print "textcase textcase = upper!";
        print "end type";
        print "";    
    }
  };  

print "type cb_save from commandbutton within " FORM;
print "integer x = 3154";
print "integer y = 132";
print "integer width = 402";
print "integer height = 112";
print "integer taborder = 240";
print "integer textsize = -8";
print "integer weight = 700";
print "fontcharset fontcharset = ansi!";
print "fontpitch fontpitch = variable!";
print "fontfamily fontfamily = swiss!";
print "string facename = \"Arial\"";
print "string text = \"Save\"";
print "end type";
print "";
print "";

print "type cb_clear from commandbutton within " FORM;
print "integer x = 3154";
print "integer y = 688";
print "integer width = 402";
print "integer height = 112 ";
print "integer taborder = 260";
print "integer textsize = -8";
print "integer weight = 700";
print "fontcharset fontcharset = ansi!";
print "fontpitch fontpitch = variable!";
print "fontfamily fontfamily = swiss!";
print "string facename = \"Arial\"";
print "string text = \"Clear\"";
print "end type";
print "";
print "event clicked;// Close parent window";
print "Close(Parent)";
print "Open(" FORM ")";
print "end event";
print "";

print "type cb_delete from commandbutton within " FORM;
print "integer x = 3154";
print "integer y = 516";
print "integer width = 402";
print "integer height = 112";
print "integer taborder = 270";
print "integer textsize = -8";
print "integer weight = 700";
print "fontcharset fontcharset = ansi!";
print "fontpitch fontpitch = variable!";
print "fontfamily fontfamily = swiss!";
print "string facename = \"Arial\"";
print "string text = \"Delete\"";
print "end type";
print "";
print "event clicked;string mssg";
print "string cnf";
print "long   cnt";
print "long   ll_tot";
print "long   ll_row";
print "long ll_ret";
print "";
print "ll_ret=Messagebox(\"Are You Sure?\",\"Click YES to DELETE\",Question!,YesNo!)";
print "";
print "if ll_ret<> 1 then";
print "    return";
print "end if  ";
print "";
print "";
print "commit;";
print "";
print "gf_testsql()";
print "";
print "mssg = \"RECORD DELETED SUCCESSFULLY\"";
print "MessageBox (\"Please_Note\", mssg)";
print "";
print "close(parent);";
print "";
print "end event";
print "";

}
