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

  1. /* color_time function */
  2. /* Prints time stamp to screen in color */
  3.  
  4. #include <stdio.h>
  5. #include <time.h>
  6.  
  7. /*   Prints current time to the screen in the form hh:mm:ss
  8.      
  9.      Arguments:
  10.      
  11.      char *format: Pointer to format for strftime function
  12.      int r1: Row in which time is to be printed (0-24)
  13.      int c1: Column in which time is to be printed (0-79)
  14.      int color: Attribute in which time is to be printed (0-255) 
  15.      
  16.      Requires colortext function from this library                  
  17.      
  18.      Returns:  0 if no error
  19.                1 if passed incorrect parameters                      */
  20.  
  21. int color_time(char *format,int r1,c1,color,max_rows)
  22.  
  23. {
  24.     /* Function declaration */
  25.     int colortext(char text[], int r1, int c1, int color, int max_rows);
  26.     
  27.      /* Variable declaration */
  28.      char out_tim[80];
  29.      struct tm *time_ptr;
  30.      time_t clock;
  31.      
  32.      /* Check for bad arguments */
  33.      if (r1<0 || r1>max_rows || c1<0 || c1>79 || color<0 || color>255)
  34.           return 1;
  35.  
  36.      /* Main function code */
  37.      time(&clock);
  38.      time_ptr = localtime(&clock);
  39.      strftime(out_tim,25,format,time_ptr);
  40.      colortext(out_tim,r1,c1,color,max_rows);
  41.      
  42.      return 0;
  43. }
  44.  
  45.