home *** CD-ROM | disk | FTP | other *** search
-
-
- Time Utilities
- by Jim Colligan
-
-
- These programs are utilities designed to be executed in .BATch
- files. The need for them came through running a bulletin board
- system, but could be used for other purposes. They were compiled
- with Borland's Turbo C compiler version 1.5 and full source code
- is included. The programs include:
-
- WAIT.EXE - This program merely goes and gets the DOS time and does
- nothing until the next whole minute rolls around. While
- this may seem like a quite trivial program, I did have a
- need for it in a .BAT file. I had a particular event set
- to execute at a set time. But for shorter events, it would
- take far less than a minute and the entire sequence would
- be repeated over and over and over until the clock finally
- ticked over to the next minute. This program can be aborted
- by pressing ^C.
-
- WAITUNTL.EXE - Similar to the above, but this one waits until a
- set hour and minute before exiting. The usage is merely:
-
- WAITUNTL xx:yy
-
- where xx is the hour (24 hour clock) and yy is the minute
- you want to "pause" until. It will work over midnight so
- a program can be set in a .BATch file and executed at any
- time and it will properly wait until the appointed hour
- before relinguishing control back to the .BATch file.
- Handy as an "alarm clock" for the system when you want a
- BAT file or other program to kick off at a certain time.
- This program can also be aborted by pressing ^C.
-
- TIMECHK.EXE - This program reads the DOS clock and merely sets an
- errorlevel for DOS accordingly. I use this on my bulletin
- board so no matter what time of the day my RUNBBS.BAT file
- is started, it'll start executing at the right place
- (different tasks/places for different times of the day).
-
- Unfortunately, there's only 256 available errorlevel codes
- available, so you can't cut up the day down to the exact
- minute. But, I have coded it so you can come down to the
- nearest 10 minutes. Not perfect, but workable.
-
- The errorlevels kicked out are determined by the formula
- (hours * 10) + (minutes / 10). Reasonably simple. What
- this means in english is that 11:17 will produce an error-
- level of 111. Here's some additional examples:
-
- Time Errorlevel
- ---- ----------
- 01:23 012
- 10:20 102
- 15:01 150
- 21:29 212
- 23:59 235
-
- I think you get the idea. The individual minutes are
- dropped (integer arithmetic) and the error code can be
- looked at as (HHM) where HH is the hour of the day and the
- M is the # of tens of minutes.
-
- A .BATch file that would use TIMECHK would look something
- like (or a portion of the .BAT file):
-
- timechk
- if errorlevel 210 goto NITETIME
- if errorlevel 170 goto EVENING
- if errorlevel 120 goto NOON
- if errorlevel 080 goto MORNING
- if errorlevel 000 goto NITETIME
-
- Where NITETIME, EVENING, NOON, and MORNING were different
- labels in a .BATch file and did different things according
- to the time of day. Note: because of the way .BATch file
- errorlevels are evaluated, you must use a reverse order
- (highest first) for proper branching. Also, if you want
- an event or condition to "start" prior to midnight and
- finish after midnight, you must use two entries (the second
- would "start" just after midnight.
-
- With all of these programs, full source code is distributed
- with them so you can modify to your heart's content. No
- guarantees of any sort are provided. I've found them useful
- and use them as distributed on my own computers including my
- bulletin board. Enjoy!!!
-
- Jim Colligan
- Fidonet 372/1 or 18/3
-
-