Commits

Anonymous committed c52729c

This utility provides a sleep like command for DOS and Windows

Comments (0)

Files changed (5)

+bcc -1- -f- -k- -mt -O1 -pr -tDc delayfor.c
+@Echo off
+rem Parameter listings for making of this app.
+rem -1- - 8086 instructions
+rem -f- - No floating point logic at all
+rem -k- - Don't bother with stack frame
+rem -mt - Tiny memory model
+rem -O1 - Optimize for smallest possible code
+rem -pr - Passing parameters to be done with registers
+rem -tDc - Make CP/M .COM program (1 segment for all segments)
+           (image with no header).
+DelayFor
+--------
+Suspends batch execution
+
+From inside a batch file the programmer has no time delay pause,
+to correct this make sure this program is on the path and use as
+follows:
+
+DELAYFOR <milliseconds>
+
+milliseconds are 1/1000 / sec, therefore to delay for 2.5 seconds
+calculate 2.5 * 1000 and use the following:
+
+DELAYFOR 2500
+
+The interval that follows is not interruptable, the user cannot
+press a key to cut-short the waiting time.  Don't over do it
+because the user will resent you and don't use a value greater
+than 65,535 because it will over-run eg. 65,357 = 2.
+
+So 65.535 secs is the maximum waiting time.
+#include <StdIO.h>
+#include <Stdlib.h>
+#ifdef __WIN32__
+#  include <Windows.H>
+#else
+#  include <DOS.h>
+#endif
+#pragma hdrstop
+
+#include "DelayFor.h"
+
+/* Simple delay program, takes one para., # ms to pause for, used in batch
+programming and the like */
+
+
+int main(int argc, char* argv[])
+{
+        unsigned int DelayTimeMs;
+
+
+        if (argc != 2) /* 1 user parameter only */
+        {
+                ShowTitle();
+                printf("Incorrect No. of parameters\n"); /* print appropriate error message */
+                printf("\n");
+                ShowSyntax();
+                return 1; /* Not done correctly */
+        }
+
+        DelayTimeMs = atoi(argv[1]); /* cvt string time into usable integer */
+        if (!DelayTimeMs)
+        {
+                ShowTitle();
+                printf("No mate, parameter must be a positive integer\n");
+                printf("\n");
+                ShowSyntax();
+                return 1;
+        }
+	#ifdef __WIN32__
+	Sleep(DelayTimeMs);
+	#else
+        delay(DelayTimeMs); /* Delay for time user said */
+	#endif
+        return 0; /* success */
+}
+
+void ShowTitle(void)
+{
+        printf("DelayFor... suspend batchfile statement by Overlord D.D.R.Palmer\n");
+        printf("----------------------------------------------------------------\n");
+        printf("\n");
+}
+
+void ShowSyntax(void)
+{
+        printf("DelayFor [Milliseconds]\n");
+}
+#ifndef __INC_DELAYFOR_H
+#define __INC_DELAYFOR_H
+/*--------------------------------------------------------------------------*/
+void ShowSyntax(void);
+void ShowTitle(void);
+/*--------------------------------------------------------------------------*/
+#endif /* __INC_DELAYFOR_H */
+bcc32 -3 -f- -k- -O1 -pr delayfor.c
+@Echo off
+rem Parameter listings for making of this app.
+rem -3 -  80386 instructions
+rem -f- - No floating point logic at all
+rem -k- - Don't bother with stack frame
+rem -O1 - Optimize for smallest possible code
+rem -pr - Passing parameters to be done with registers