home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / vrac / panshr24.zip / SHOWTIME.C < prev    next >
Text File  |  1991-09-16  |  2KB  |  80 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <time.h>
  4. #include "panel.h"
  5. #include "keys.h"
  6.  
  7. float random();
  8.  
  9. char buf[255], *window =
  10. "size %d %d %d %d\n"
  11. "background 1\n"
  12. "tag $ p\n"
  13. "tag # ph7 time\n"
  14. "$\n"
  15. "  #                         $\n";
  16.  
  17. main()
  18.     {
  19.     time_t ltime, prev = 0;
  20.     char *stime;
  21.     int row = 9, col = 23;
  22.  
  23.     pan_init();
  24.  
  25.     while (!kbhit())
  26.         {
  27.         time(<ime);
  28.  
  29.         if (ltime >= prev+10)    /* every 10 seconds relocate time window */
  30.             {
  31.             if (prev != 0)
  32.                 pan_destroy();
  33.             row = random() * 22;
  34.             col = random() * 50;
  35.             sprintf(buf, window, row, col, row+2, col+29);
  36.             pan_activate(buf);
  37.             prev = ltime;
  38.             }
  39.  
  40.         stime = ctime(<ime);
  41.         stime[24] = 0;
  42.         pan_put_field("time", 1, stime);
  43.         }
  44.  
  45.     pan_get_key();
  46.  
  47.     pan_destroy();
  48.     }
  49.  
  50.  
  51. /******************************************************************************
  52. *
  53. * Function Name : random()
  54. * Written By    : JJB
  55. * Created       : 03/16/90
  56. * Description   : Produces a pseudo random number.
  57. * Arguments     : none
  58. * Returns       : floating point number between zero and one.
  59. * Modifications :
  60. *
  61. *****************************************************************************/
  62.  
  63. float random()
  64.    {
  65.    static unsigned long a;
  66.    static int first = 1;
  67.  
  68.    if (first)
  69.        {
  70.        time(&a);
  71.        first = 0;
  72.        }
  73.  
  74.    a = (a * 125) % 2796203;
  75.    return ((float) a / 2796203);
  76.  
  77.    }
  78.  
  79.  
  80.