/* ** Example Data Entry program */ #include "windows.h" /* ALWAYS */ main() /* simple test pgm */ { WIFORM frm; /* our form */ WINDOWPTR w1; /* window to use */ int month, day, year; /* date stuff */ int hrs, mins, secs; /* time stuff */ float fval; /* float stuff */ int ac, nnx, num; /* phone stuff */ int ival; /* int stuff */ unsigned uval; /* unsigned stuff */ long lval; /* long stuff */ int bval; /* bool stuff */ unsigned long ulval; /* unsigned long stuff */ double dval; /* double stuff */ char *hmsg, *emsg; /* help and error messages */ char dbuff[10]; /* date buffer */ char tbuff[10]; /* time buffer */ char txb1[120], txb2[120], txb3[120]; /* text buffers */ char fbuf[30]; /* float buffer */ char pbuff[30]; /* phone buffer */ char ibuff[30]; /* int buffer */ char lbf[30]; /* long buffer */ char bool[30]; /* bool buffer */ char ubf[30]; /* unsigned buffer */ char pwbuf[120]; /* password buffer */ char ulbf[30]; /* unsigned long buffer */ char dbl[30]; /* double buffer */ unsigned atrib; /* attribute */ atrib = (BLUE<<4 | WHITE); /* simple attributes */ wn_init(); w1=wn_open(0,5,10,38,15,NVIDEO,NVIDEO);/* open a window */ if(!w1) exit(0); /* die if error */ /* init edit buffers */ ibuff[0] = NUL; /* integer */ dbuff[0] = NUL; /* date */ tbuff[0] = NUL; /* time */ txb1[0] = NUL; /* text field # 1 */ txb2[0] = NUL; /* text field # 2 */ txb3[0] = NUL; /* text field # 3 */ fbuf[0] = NUL; /* float */ pbuff[0] = NUL; /* phone */ ubf[0] = NUL; /* unsigned */ lbf[0] = NUL; /* long */ bool[0] = NUL; /* logical */ pwbuf[0] = NUL; /* password */ ulbf[0] = NUL; /* unsigned long */ dbl[0] = NUL; /* double */ hmsg = "Sample Help Message"; /* help & error messages */ emsg = "Sample Error Message"; /* in actual practice, each */ /* field should have its own */ /* IMMEDIATE XEQ first */ wn_dtext(XEQ,NFRM,NFLD,w1,0,1,"DTEXT display text line 1!!"); wn_guint(XEQ,NFRM,NFLD,w1,1,1,"Uint: ", atrib, '_',&uval,6,0,10000,ubf,hmsg,emsg); wn_gdate(XEQ,NFRM,NFLD,w1,2,1,"Date: ", atrib,'_',&month,&day,&year,dbuff,hmsg,emsg); wn_gtime(XEQ,NFRM,NFLD,w1,3,1,"Time: ", atrib,'_',&hrs,&mins,&secs,tbuff,hmsg,emsg); wn_gtext(XEQ,NFRM,NFLD,w1,4,1,"Text: ", atrib,'_',30,txb1,hmsg,emsg); wn_gtext(XEQ,NFRM,NFLD,w1,5,1,"Text: ", atrib,'_',30,txb2,hmsg,emsg); wn_gtext(XEQ,NFRM,NFLD,w1,6,1,"Text: ", atrib,'_',30,txb3,hmsg,emsg); wn_gfloat(XEQ,NFRM,NFLD,w1,7,1,"Float: ", atrib, '_',&fval,8,2,-10000.0,10000.0,fbuf,hmsg,emsg); wn_gphone(XEQ,NFRM,NFLD,w1,8,1,"Phone: ", atrib, '_',&ac,&nnx,&num,pbuff,hmsg,emsg); wn_glong(XEQ,NFRM,NFLD,w1,9,1,"Long: ", atrib, '_',&lval,6,-10000l,10000l,lbf,hmsg,emsg); wn_gbool(XEQ,NFRM,NFLD,w1,10,1,"BOOL: ", atrib, '_',&bval,bool,hmsg,emsg); wn_gint(XEQ,NFRM,NFLD,w1,11,1,"Int: ", atrib, '_',&ival,6,-10000,10000,ibuff,hmsg,emsg); wn_gpword(XEQ,NFRM,NFLD,w1,12,1,"PWD: ", atrib, '_',30,pwbuf,hmsg,emsg); wn_gulong(XEQ,NFRM,NFLD,w1,13,1,"Ulong:", atrib, '_',&ulval,10,0l,0xf5000000l,ulbf,hmsg,emsg); wn_gdouble(XEQ,NFRM,NFLD,w1,14,1,"Doubl: ", atrib, '_',&dval,8,2,-10000.0,10000.0,dbl,hmsg,emsg); v_wtty(7); /* ding the bell and */ v_getch(); /* wait for a key to be struck */ wn_clr(w1); /* clear the window */ /* open form */ frm = wn_frmopn(17); /* 15 fields */ if(!frm) exit(0); /* die if error */ /* SETup the form... note that since the edit buffers were not reset, the fields will be pre filled!! */ wn_dtext(SET,frm,0,w1,0,1,"DTEXT display text line 1!!"); wn_guint(SET,frm,1,w1,1,1,"Uint: ", atrib, '_',&uval,6,0,10000,ubf,hmsg,emsg); wn_gdate(SET,frm,2,w1,2,1,"Date: ", atrib,'_',&month,&day,&year,dbuff,hmsg,emsg); wn_gtime(SET,frm,3,w1,3,1,"Time: ", atrib,'_',&hrs,&mins,&secs,tbuff,hmsg,emsg); wn_gtext(SET,frm,4,w1,4,1,"Text: ", atrib,'_',30,txb1,hmsg,emsg); wn_gtext(SET,frm,5,w1,5,1,"Text: ", atrib,'_',30,txb2,hmsg,emsg); wn_gtext(SET,frm,6,w1,6,1,"Text: ", atrib,'_',30,txb3,hmsg,emsg); wn_gfloat(SET,frm,7,w1,7,1,"Float: ", atrib, '_',&fval,8,2,-10000.0,10000.0,fbuf,hmsg,emsg); wn_gphone(SET,frm,8,w1,8,1,"Phone: ", atrib, '_',&ac,&nnx,&num,pbuff,hmsg,emsg); wn_glong(SET,frm,9,w1,9,1,"Long: ", atrib, '_',&lval,6,-10000l,10000l,lbf,hmsg,emsg); wn_gbool(SET,frm,10,w1,10,1,"BOOL: ", atrib, '_',&bval,bool,hmsg,emsg); wn_gint(SET,frm,11,w1,11,1,"Int: ", atrib, '_',&ival,6,-10000,10000,ibuff,hmsg,emsg); wn_gpword(SET,frm,12,w1,12,1,"PWD: ", atrib, '_',30,pwbuf,hmsg,emsg); wn_gulong(SET,frm,13,w1,13,1,"Ulong:", atrib, '_',&ulval,10,0l,0xf5000000l,ulbf,hmsg,emsg); wn_gdouble(SET,frm,14,w1,14,1,"Doubl: ", atrib, '_',&dval,8,2,-10000.0,10000.0,dbl,hmsg,emsg); wn_frmget(frm); /* read the form */ wn_frmcls(frm); /* close the form */ wn_close(w1); /* then the window */ wn_exit(); /* Display results */ printf("DATE %d/%d/%d\n", month,day,year); printf("TIME %02d:%02d:%02d\n",hrs,mins,secs); printf("TEXT %s\n",txb1); printf("TEXT %s\n",txb2); printf("TEXT %s\n",txb3); printf("INT %d\n",ival); printf("UINT %u\n",uval); printf("FLOAT %f\n",fval); printf("PHONE %d-%d-%d\n",ac,nnx,num); printf("LONG %ld\n",lval); printf("BOOL %d\n", bval); printf("PWORD %s\n",pwbuf); printf("ULONG %lu\n",ulval); printf("DBL %lf\n",dval); exit(0); }