home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / vrac / pclcjs.zip / COLORTXT.C < prev    next >
C/C++ Source or Header  |  1992-12-21  |  2KB  |  70 lines

  1.  
  2. /* colortext library function copyright 1991 by Chuck Steenburgh */
  3.  
  4. /*  This function writes a string to the screen with color attributes. 
  5.     The following arguments MUST be passed to the function:
  6.     
  7.        text[]: this char array contains the string to be printed
  8.        
  9.        r1: this int variable contains the screen row in which the
  10.             text is to be printed.  Must lie between 0 and 24.
  11.             
  12.        c1: this int contains the screen column in which text printing
  13.             is to begin.  Must lie between 0 and 79.
  14.             
  15.        color: this int represents the background/foreground color which
  16.             is to be used ONLY for printing text[].  The rest of the 
  17.             screen is not affected.  The color value is arrived at by
  18.             the following method:
  19.             
  20.             Background colors:
  21.             
  22.             Black          0          Blue         16
  23.             Green         32          Cyan         48
  24.             Red           64          Magenta      80
  25.             Brown         96          White       112
  26.             
  27.             Foreground colors:
  28.  
  29.             Black          0          Blue          1
  30.             Green          2          Cyan          3
  31.             Red            4          Magenta       5
  32.             Brown          6          White         7
  33.  
  34.     Add together the values listed for your choice of background and
  35. foreground colors to obtain a value for color.  For special attributes,
  36. add the following values:
  37.  
  38.                  Bold foreground        +8
  39.                  Blinking foreground  +128
  40.                  
  41.  
  42.      Returns: 0 if no error
  43.               1 if passed invalid argument(s)
  44.  
  45.     Chuck Steenburgh
  46.     Power C Users Group
  47.     CIS IBM Programming Forum
  48.     72330,1776                                                        */
  49.  
  50.  
  51. #include <bios.h>
  52.  
  53. int colortext(char text[], int r1, int c1, int color, max_rows)
  54. {
  55.     /* Local variable */
  56.     int counter;
  57.     
  58.     /* Check valid arguments */
  59.     if (r1<0 || r1>max_rows || c1<0 || c1>79 || color<0 || color>255)
  60.         return 1;
  61.         
  62.     poscurs(r1,c1);
  63.     for (counter=0;counter<strlen(text);counter++) {
  64.         writechs(text[counter],color,1);
  65.         poscurs(r1,c1+counter+1);
  66.     }
  67.     
  68.     return 0;
  69. }
  70.