home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / prog1 / boss719a.lzh / SAMPLE.C < prev    next >
C/C++ Source or Header  |  1990-03-23  |  7KB  |  135 lines

  1. /*
  2. ** Example Data Entry program
  3. */
  4.  
  5. #include "windows.h"                    /* ALWAYS */
  6.  
  7. main()                                  /* simple test pgm */
  8. {
  9. WIFORM frm;                             /* our form */
  10. WINDOWPTR w1;                           /* window to use */
  11. int month, day, year;                   /* date stuff */
  12. int hrs, mins, secs;                    /* time stuff */
  13. float fval;                             /* float stuff */
  14. int ac, nnx, num;                       /* phone stuff */
  15. int ival;                               /* int stuff */
  16. unsigned uval;                          /* unsigned stuff */
  17. long lval;                              /* long stuff */
  18. int bval;                               /* bool stuff */
  19. unsigned long ulval;                    /* unsigned long stuff */
  20. double dval;                            /* double stuff <grin (oreo)> */
  21. char *hmsg, *emsg;                      /* help and error messages */
  22. char dbuff[10];                         /* date buffer */
  23. char tbuff[10];                         /* time buffer */
  24. char txb1[120], txb2[120], txb3[120];   /* text buffers */
  25. char fbuf[30];                          /* float buffer */
  26. char pbuff[30];                         /* phone buffer */
  27. char ibuff[30];                         /* int buffer */
  28. char lbf[30];                           /* long buffer */
  29. char bool[30];                          /* bool buffer */
  30. char ubf[30];                           /* unsigned buffer */
  31. char pwbuf[120];                        /* password buffer */
  32. char ulbf[30];                          /* unsigned long buffer */
  33. char dbl[30];                           /* double buffer <grin (devices)> */
  34.  
  35. unsigned atrib;                         /* attribute */
  36.  
  37.   atrib = (BLUE<<4 | WHITE);            /* simple attributes */
  38.  
  39.   wn_init();
  40.   w1=wn_open(0,5,10,38,15,NVIDEO,NVIDEO);/* open a window */
  41.   if(!w1) exit(0);                      /* die if error */
  42.  
  43.                                         /* init edit buffers */
  44.   ibuff[0] = NUL;                       /* integer */
  45.   dbuff[0] = NUL;                       /* date */
  46.   tbuff[0] = NUL;                       /* time */
  47.   txb1[0] = NUL;                        /* text field # 1 */
  48.   txb2[0] = NUL;                        /* text field # 2 */
  49.   txb3[0] = NUL;                        /* text field # 3 */
  50.   fbuf[0] = NUL;                        /* float */
  51.   pbuff[0] = NUL;                       /* phone */
  52.   ubf[0] = NUL;                         /* unsigned */
  53.   lbf[0] = NUL;                         /* long */
  54.   bool[0] = NUL;                        /* logical */
  55.   pwbuf[0] = NUL;                       /* password */
  56.   ulbf[0] = NUL;                        /* unsigned long */
  57.   dbl[0] = NUL;                         /* double */
  58.  
  59.   hmsg = "Sample Help Message";         /* help & error messages */
  60.   emsg = "Sample Error Message";        /* in actual practice, each */
  61.                                         /* field should have its own */
  62.  
  63.                                         /* IMMEDIATE XEQ first */
  64.  
  65.   wn_dtext(XEQ,NFRM,NFLD,w1,0,1,"DTEXT display text line 1!!"); 
  66.   wn_guint(XEQ,NFRM,NFLD,w1,1,1,"Uint: ", atrib, '_',&uval,6,0,10000,ubf,hmsg,emsg);
  67.   wn_gdate(XEQ,NFRM,NFLD,w1,2,1,"Date: ", atrib,'_',&month,&day,&year,dbuff,hmsg,emsg);
  68.   wn_gtime(XEQ,NFRM,NFLD,w1,3,1,"Time: ", atrib,'_',&hrs,&mins,&secs,tbuff,hmsg,emsg);
  69.   wn_gtext(XEQ,NFRM,NFLD,w1,4,1,"Text: ", atrib,'_',30,txb1,hmsg,emsg);
  70.   wn_gtext(XEQ,NFRM,NFLD,w1,5,1,"Text: ", atrib,'_',30,txb2,hmsg,emsg);
  71.   wn_gtext(XEQ,NFRM,NFLD,w1,6,1,"Text: ", atrib,'_',30,txb3,hmsg,emsg);
  72.   wn_gfloat(XEQ,NFRM,NFLD,w1,7,1,"Float: ", atrib, '_',&fval,8,2,-10000.0,10000.0,fbuf,hmsg,emsg);
  73.   wn_gphone(XEQ,NFRM,NFLD,w1,8,1,"Phone: ", atrib, '_',&ac,&nnx,&num,pbuff,hmsg,emsg); 
  74.   wn_glong(XEQ,NFRM,NFLD,w1,9,1,"Long: ",   atrib, '_',&lval,6,-10000l,10000l,lbf,hmsg,emsg);
  75.   wn_gbool(XEQ,NFRM,NFLD,w1,10,1,"BOOL: ",  atrib, '_',&bval,bool,hmsg,emsg);
  76.   wn_gint(XEQ,NFRM,NFLD,w1,11,1,"Int: ",    atrib, '_',&ival,6,-10000,10000,ibuff,hmsg,emsg);
  77.   wn_gpword(XEQ,NFRM,NFLD,w1,12,1,"PWD:  ", atrib, '_',30,pwbuf,hmsg,emsg);
  78.   wn_gulong(XEQ,NFRM,NFLD,w1,13,1,"Ulong:", atrib, '_',&ulval,10,0l,0xf5000000l,ulbf,hmsg,emsg);
  79.   wn_gdouble(XEQ,NFRM,NFLD,w1,14,1,"Doubl: ", atrib, '_',&dval,8,2,-10000.0,10000.0,dbl,hmsg,emsg);
  80.   v_wtty(7);                            /* ding the bell and */
  81.   v_getch();                            /* wait for a key to be struck */
  82.   wn_clr(w1);                           /* clear the window */
  83.                                         /* open form */
  84.   frm = wn_frmopn(17);                  /* 15 fields */
  85.   if(!frm) exit(0);                     /* die if error */
  86.  
  87. /*
  88.    SETup the form... note that since the edit buffers were not reset, 
  89.    the fields will be pre filled!! 
  90. */
  91.  
  92.   wn_dtext(SET,frm,0,w1,0,1,"DTEXT display text line 1!!"); 
  93.   wn_guint(SET,frm,1,w1,1,1,"Uint: ", atrib, '_',&uval,6,0,10000,ubf,hmsg,emsg);
  94.   wn_gdate(SET,frm,2,w1,2,1,"Date: ", atrib,'_',&month,&day,&year,dbuff,hmsg,emsg);
  95.   wn_gtime(SET,frm,3,w1,3,1,"Time: ", atrib,'_',&hrs,&mins,&secs,tbuff,hmsg,emsg);
  96.   wn_gtext(SET,frm,4,w1,4,1,"Text: ", atrib,'_',30,txb1,hmsg,emsg);
  97.   wn_gtext(SET,frm,5,w1,5,1,"Text: ", atrib,'_',30,txb2,hmsg,emsg);
  98.   wn_gtext(SET,frm,6,w1,6,1,"Text: ", atrib,'_',30,txb3,hmsg,emsg);
  99.   wn_gfloat(SET,frm,7,w1,7,1,"Float: ", atrib, '_',&fval,8,2,-10000.0,10000.0,fbuf,hmsg,emsg);
  100.   wn_gphone(SET,frm,8,w1,8,1,"Phone: ", atrib, '_',&ac,&nnx,&num,pbuff,hmsg,emsg); 
  101.   wn_glong(SET,frm,9,w1,9,1,"Long: ",   atrib, '_',&lval,6,-10000l,10000l,lbf,hmsg,emsg);
  102.   wn_gbool(SET,frm,10,w1,10,1,"BOOL: ", atrib, '_',&bval,bool,hmsg,emsg);
  103.   wn_gint(SET,frm,11,w1,11,1,"Int: ",   atrib, '_',&ival,6,-10000,10000,ibuff,hmsg,emsg);
  104.   wn_gpword(SET,frm,12,w1,12,1,"PWD:  ", atrib, '_',30,pwbuf,hmsg,emsg);
  105.   wn_gulong(SET,frm,13,w1,13,1,"Ulong:", atrib, '_',&ulval,10,0l,0xf5000000l,ulbf,hmsg,emsg);
  106.   wn_gdouble(SET,frm,14,w1,14,1,"Doubl: ", atrib, '_',&dval,8,2,-10000.0,10000.0,dbl,hmsg,emsg);
  107.  
  108.   if(wn_frmget(frm) == ESC_CODE)        /* read the form */
  109.     v_wtty(7);                          /* beep if escape was pressed */
  110.  
  111.   wn_frmcls(frm);                       /* close the form */
  112.   wn_close(w1);                         /* then the window */
  113.  
  114.   wn_exit();
  115.                                         
  116.                                         /* Display results */
  117.   printf("DATE   %d/%d/%d\n", month,day,year);
  118.   printf("TIME   %02d:%02d:%02d\n",hrs,mins,secs);
  119.   printf("TEXT   %s\n",txb1);
  120.   printf("TEXT   %s\n",txb2);
  121.   printf("TEXT   %s\n",txb3);
  122.   printf("INT    %d\n",ival); 
  123.   printf("UINT   %u\n",uval);
  124.   printf("FLOAT  %f\n",fval);
  125.   printf("PHONE  %d-%d-%d\n",ac,nnx,num);
  126.   printf("LONG   %ld\n",lval);
  127.   printf("BOOL   %d\n", bval);
  128.   printf("PWORD  %s\n",pwbuf);
  129.   printf("ULONG  %lu\n",ulval);
  130.   printf("DBL    %lf\n",dval);
  131.  
  132.   exit(0);
  133. }
  134.  
  135.