home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / DELAY.ZIP / DELAY.C next >
C/C++ Source or Header  |  1991-06-20  |  935b  |  48 lines

  1. /*
  2.  *  DELAY - A program to sleep for a specified number of milliseconds
  3.  *
  4.  *  Dave Briccetti, June 20, 1991
  5.  */
  6.  
  7.  
  8. #include "stdio.h"
  9.  
  10. #define INCL_DOSPROCESS
  11. #include <os2.h>
  12.  
  13. SHORT main (SHORT cArgs, PSZ apszArgs[])
  14. {
  15.     BOOL    fParmsValid = FALSE;
  16.     LONG    lDelayMilliseconds;
  17.     SHORT   Rc;
  18.  
  19.  
  20.     /*
  21.      *  Verify that one argument is provided, and that it is valid
  22.      */
  23.  
  24.     if (cArgs == 2)
  25.         if (sscanf (apszArgs [1], "%ld", &lDelayMilliseconds) == 1)
  26.             if (lDelayMilliseconds >= 0)
  27.                 fParmsValid = TRUE;
  28.  
  29.  
  30.     /*
  31.      *  Call DosSleep if arg is valid, otherwise show an error message
  32.      */
  33.  
  34.     if (fParmsValid)
  35.     {
  36.         DosSleep (lDelayMilliseconds);
  37.         Rc = 0;
  38.     }
  39.     else
  40.     {
  41.         puts ("Syntax: DELAY n");
  42.         puts ("   Where 'n' is the number of milliseconds to delay");
  43.         Rc = 1;
  44.     }
  45.  
  46.     return Rc;
  47. }
  48.