home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 05oslib / bios / writemsg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  867 b   |  41 lines

  1. /*
  2.  *    writemsg -- displays a message in a field of the prevailing
  3.  *    video attribute and returns the number of displayable message
  4.  *    characters written; truncates the message if its too long
  5.  *    to fit in the field
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <local\std.h>
  10.  
  11. int writemsg(r, c, w, s1, s2, pg)
  12. int r, c, w ;
  13. char *s1, *s2;
  14. int pg;
  15. {
  16.     int n = 0;
  17.     char *cp;
  18.  
  19.     /* display first part of the message */
  20.     if (s1 != NULL)
  21.         for (cp = s1; *cp != '\0' && n < w; ++n, ++cp) {
  22.             putcur(r, c + n, pg);
  23.             writec(*cp, 1, pg);
  24.         }
  25.  
  26.     /* display second part of the message */
  27.     if (s2 != NULL)
  28.         for (cp = s2; *cp != '\0' && n < w; ++n, ++cp) {
  29.             putcur(r, c + n, pg);
  30.             writec(*cp, 1, pg);
  31.         }
  32.  
  33.     /* pad the remainder of the field, if any, with spaces */
  34.     if (n < w) {
  35.         putcur(r, c + n, pg);
  36.         writec(' ', w - n, pg);
  37.     }
  38.  
  39.     return (n);
  40. }
  41.