home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / dos / countdn.lzh / COUNTDN.C next >
Text File  |  1980-01-01  |  2KB  |  85 lines

  1. /*
  2.   COUNTDOWN Ver 1.11           This Program is PUBLIC DOMAIN
  3.   Author: Kirby Angell                Do with it what you will
  4.   Date : Oct 88
  5.  
  6.   Commets to the author may be addressed to:
  7.     via NetMail address 147/42
  8.     BBS Number (405)771-5954
  9.     Or by snail at
  10.         12500 Teakwood Rd
  11.         Edmond, OK  73013
  12. */
  13.  
  14. #define MAXLEN 80
  15. #define LIMIT 30
  16. #define OK 0
  17. #define ERROR 1
  18. #include <stdlib.h>
  19.  
  20. logo()
  21. {
  22.   printf("\nCOUNTDOWN ver 1.11\n");
  23.  
  24. }
  25.  
  26. argcheck(int count, char *param)
  27. {
  28.   if (count < 2) {
  29.     printf("\nUSAGE: COUNTDN 2 50 Hold_for_RoboCoder_or_press_any_key\n");
  30.     printf("Would exit with errorlevel 2 if you press a key before the program ends,\n");
  31.     printf("or exit in 50 seconds with errorlevel %d if you don't.\n",OK);
  32.     printf("This would also print out \"Hold for RoboCoder or press any key\"\n");
  33.     printf("as the prompt. The maximum prompt length is %d.\n",MAXLEN);
  34.     printf("The program exits with errorlevel %d if there is are improper command line\n",ERROR);
  35.     printf("arguments.\n");
  36.     exit(ERROR);
  37.   }
  38.   if ((atoi(param) == OK) || (atoi(param) == ERROR)) {
  39.     printf("\nERROR: Errorlevel cannot equal %d or %d\n",OK,ERROR);
  40.     exit(ERROR);
  41.   }
  42. }
  43.  
  44. stripblanks(char *in)
  45. {
  46.   while (*in++ != '\0')
  47.     if (*in == '_')
  48.       *in = ' ';
  49. }
  50.  
  51. main(int argc, char *argv[])
  52. {
  53.   int timer;
  54.   int errorlevel;
  55.   int top;
  56.   char prompt[MAXLEN] = "Press any key to exit with errorlevel...\n\0";
  57.  
  58.   logo();
  59.   argcheck(argc,argv[1]);
  60.  
  61.   errorlevel = atoi(argv[1]);
  62.   if (argc >= 3)
  63.     top = atoi(argv[2]);
  64.   else
  65.     top = LIMIT;
  66.  
  67.   if (argc == 4)
  68.     stripblanks(strcpy(prompt,argv[3]));
  69.  
  70.   printf("%s\n",prompt);
  71.  
  72.   for (timer = top;timer > 0; --timer) {
  73.     printf(".");
  74.     delay(1000);
  75.     if (kbhit())
  76.     {
  77.       getch();
  78.       printf("\n");
  79.       exit(errorlevel);
  80.     }
  81.   }
  82.   printf("\n");
  83.   return OK;
  84. }
  85.