home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / speechlb.zip / Spkclock.C < prev    next >
C/C++ Source or Header  |  1999-10-22  |  1KB  |  79 lines

  1.  
  2. #include "speech.h"
  3. #include <dos.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #define INCL_WINSHELLDATA       /* Window Shell functions       */
  7. #include <os2.h>
  8.  
  9. int interval=15;
  10. int ampm=1;
  11. int voice=0;
  12.  
  13.  
  14. void getini(void)
  15. {
  16.  char ip[80];
  17.  ampm = PrfQueryProfileInt(HINI_USERPROFILE,"PM_National","iTime",0);
  18.  ampm &= 1;
  19. }
  20.  
  21. void saytime(struct time *tp)
  22. {
  23.  char str[100];
  24.  char *ap=" |A M| ";
  25.  char ts[5];
  26.  int tmp;
  27.  strcpy(str,"~M(0) The time is ");
  28.  str[3]='0'+voice;
  29.  tmp=tp->ti_hour;
  30.  if (ampm==0)
  31.  {
  32.    if (tmp >=12) {ap[2]='P'; tmp-=12;}
  33.    if (tmp == 0) tmp=12;
  34.    ap[4]='M';
  35.  }
  36.  else
  37.  {
  38.    ap[2]=' ';
  39.    ap[4]=' ';
  40.  }
  41.  itoa(tmp,ts,10);
  42.  strcat(str,ts);
  43.  strcat(str," hours ");
  44.  if(tp->ti_min != 0)
  45.  {
  46.    strcat(str,"and ");
  47.    itoa(tp->ti_min,ts,10);
  48.    strcat(str,ts);
  49.    strcat(str," minutes ");
  50.  }
  51.  strcat(str,ap);
  52.  audio_init(2);
  53.  say_string(str);
  54.  sleep(60);
  55.  audio_term();
  56. }
  57.  
  58.  
  59. void main(int envc,char *env[])
  60. {
  61.   struct time timep;
  62.   int i;
  63.   if (envc>1) i=atoi(env[1]);
  64.   if (i>9) interval=i; else voice=i;
  65.   if (envc>2) i=atoi(env[2]);
  66.   if (i>9) interval=i; else voice=i;
  67.   if (interval>=60) interval=15;
  68.   getini();
  69.   sleep(60);
  70.   gettime(&timep);
  71.   for(;;)
  72.   {
  73.     sleep(60-timep.ti_sec);
  74.     gettime(&timep);
  75.     if((timep.ti_min % interval)==0) saytime(&timep);
  76.   }
  77. }
  78.  
  79.