home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_02 / 8n02087a < prev    next >
Text File  |  1990-03-01  |  4KB  |  122 lines

  1.                             Listing 3
  2.  
  3. /*-----------------------------------------------------------------------
  4. |          This program is an example of how the C arrays of            |
  5. |       structures generated by Screen Machine can be displayed.     |
  6. |                                                                       |
  7. |          Note:                                                        |       
  8. |          Screen Machine always generates the structure "_scrn".  If   |
  9. |          you are including more than one screen generated by Screen   |
  10. |          Machine in a given program, only one declaration of the      |
  11. |          "_scrn" structure should be copied into the program.         |
  12. -----------------------------------------------------------------------*/
  13.  
  14. /*various include files*/
  15. #include <stdio.h>
  16. #include <graph.h>
  17. #include <bios.h>
  18. #include <dos.h>
  19.  
  20. #define FALSE 0
  21. #define TRUE 1
  22. #define VIDEO 0x10                              /*software interrupt 0x10 */
  23. #define WRITE_ATTR_CHAR 9                       /*function 9 */
  24.  
  25. void disp_screen(struct _scrn *, unsigned short );
  26.  
  27. struct _scrn    {
  28.         char    *chrs;
  29.         char    cw;
  30.         char    rw;
  31.         char    att;
  32.         };
  33.  
  34. struct _scrn screen_mainmenu[]={
  35.  
  36.     {"╔════════════════════════════════════╗",21,6,31},
  37.     {"║                                    ║",21,7,31},
  38.     {"║        Grade Book Main Menu        ║",21,8,31},
  39.     {"║                                    ║",21,9,31},
  40.     {"║        1) Scan Grades              ║",21,10,31},
  41.     {"║        2) Edit/View Grades         ║",21,11,31},
  42.     {"║        3) Print Grade Book         ║",21,12,31},
  43.     {"║        4) Scan Names               ║",21,13,31},
  44.     {"║        5) Print Rosters            ║",21,14,31},
  45.     {"║        6) Other Print Functions    ║",21,15,31},
  46.     {"║        7) Set Teacher Information  ║",21,16,31},
  47.     {"║        8) Drop Lowest Grade        ║",21,17,31},
  48.     {"║        9) Exit                     ║",21,18,31},
  49.     {"║                                    ║",21,19,31},
  50.     {"║     For help, press <Alt><H>.      ║",21,20,31},
  51.     {"╚════════════════════════════════════╝",21,21,31},
  52.     {"\0",0,0,0}
  53.     };
  54.  
  55.  
  56. long color_back_grnd= 1;                        /*all screens will use a blue
  57.                                                   background*/
  58.  
  59.  
  60. main()
  61. {
  62.  
  63. disp_screen(screen_mainmenu, TRUE);        /*clear screen and then display the
  64.                                              screen defined by screen_mainmenu*/
  65.  
  66. }
  67.  
  68. /*-----------------------------------------------------------
  69. | disp_screen - Use ptr passed to array of structures        |
  70. |        containing &text; col; row; and attribute.  |
  71. |        Use BIOS int 10h function 9 to display the  |
  72. |        data.                           |
  73. |                                |                      
  74. |        If cls_flag is TRUE, clear the screen before|
  75. |               displaying the data.  When clearing the     |
  76. |               screen, use the attribute defined in the    |
  77. |               variable color_back_grnd                    |
  78. |                                                           |
  79. ------------------------------------------------------------*/
  80.  
  81. void disp_screen(p, cls_flag)
  82. struct _scrn *p;
  83. unsigned short cls_flag;
  84. {
  85. char wcol;
  86. char * wsptr;
  87.  
  88. union REGS inregs, outregs;
  89.  
  90.  
  91.         if (cls_flag)
  92.         {
  93.                 _setbkcolor(color_back_grnd);
  94.                 _clearscreen(_GCLEARSCREEN);
  95.         }
  96.  
  97.     inregs.h.ah = WRITE_ATTR_CHAR;          /*print char and attribute*/
  98.     inregs.x.cx = 1;                    /*print 1 char*/
  99.  
  100.     while ( *(p->chrs) )
  101.     {
  102.         wsptr=p->chrs;                    /*get ptr to string*/
  103.         wcol=p->cw;
  104.  
  105.         inregs.h.bh = 0;                   /*video page 0*/
  106.         inregs.h.bl = p->att;                      /*attribute to use */
  107.  
  108.         while (inregs.h.al = *wsptr++)           /*char to print*/
  109.         {
  110.  
  111.                                             /*position the cursor*/
  112.  
  113.             _settextposition( (short) p->rw, (short) wcol++);             
  114.  
  115.             int86 ( VIDEO, &inregs, &outregs ); /*print with BIOS*/
  116.         }
  117.  
  118.         p++;
  119.     }
  120.  
  121. }
  122.