home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Beijing Paradise BBS Backup
/
PARADISE.ISO
/
software
/
BBSDOORW
/
DAYNBR.ZIP
/
DAYNBR.DOC
< prev
Wrap
Text File
|
1985-10-27
|
7KB
|
151 lines
DAYNBR -- Version 1.0
Copyright (c) 1985 by Ben Baker
Released for free non-commercial use and distribution.
Reasonable licensing arrangements for commercial use may be
made by contacting the author:
Ben Baker
P.O. Box 425
Godfrey, IL 62035
Fido 100/76
Purpose: Edit a DOS command to contain reference(s) to Julian
day-of-year, then execute the command.
Format: DAYNBR [ /{D|+|-}<n> ] <command> <parameters>
Type: External.
Remarks: When multiple files containing similar data must coexist on
the DOS file system, they must have unique names. If the
files are of a periodic nature, a natural naming convention
would embed the creation date in the file name.
"Day-of-year" number is a frugal choice since it only
requires 3 digits and can even be used as the file name
extension.
When periodic maintenance is required to create or
manipulate these files, the use of "wild-card" names may be
inconvenient or even impossible, precluding the use of
batch files to do the work.
This program will calculate the correct day number, edit a
DOS command's parameters to contain the day number, then
execute the command.
The <command> to be executed may be a batch file name or
any internal or external DOS command except batch
conditional commands (eg. IF).
The <parameters> for <command> contain one or more "edit
patterns" in the form:
@<ccc>
The "at sign" (@) is a literal lead-in character which
introduces the pattern, and <ccc> is any string of three
characters. Characters in the pattern other than pound
sign (#) are copied as-is to the command parameter. Pound
signs (#) are replaced by the corresponding digit of the
calculated day number. In other words, if the second
character of the pattern is a pound sign (c#c), the tens
digit of day number is copied to that position in the
parameter being edited. This ability allows you to deal
effectively with squeezed (#Q#) and archived (A##) versions
of the files.
If an actual at sign is required in a prarmeter, it may be
entered as two successive at signs (@@). This may occur on
successive invocations of DAYNBR, for example. (See
example below.)
When DAYNBR begins, it sets a "reference date" to today's
date. If no optional switches appear before <command>,
DAYNBR calculates the day number for today and uses it in
editing. The switches have the effect of modifying the
reference date used in editing.
/+<n> and /-<n> add <n> days to or subtract <n> days from
the reference date respectively. <n> may be any number in
the range of 0 to 32767. Note that the plus sign (+) MAY
NOT be omitted. Unsinged <n> is reserved for a different
context in a possible future enhancement.
/D<n> selects a specific day of the week from a 7-day
window ending with the current reference date as the new
reference date. <n> must be a single digit in the range 0
to 6, and corresponds to the days Sunday through Saturday.
Switches may be used in combination, and are interpreted
from left to right.
DAYNBR invokes a new copy of the COMMAND.COM to execute
<command>. Therefore COMMAND.COM must be in either the
current directory, or a directory specified in a PATH
command.
Since the command processor does not pass back any error
codes returned by the executed program, DAYNBR cannot
return them to your batch file for testing. DAYNBR
terminates with ERRORLEVEL = 1 if it encounters any error
while processing switches or edit patterns. Otherwise it
executes the <command> and returns ERRORLEVEL = 0.
Examples: Most of the following examples use the ECHO command. This
is an excellent way to excercize DAYNBR until you are fully
familiar with how it works because results are immediate
and it can do nothing harmful.
Display today's day number:
DAYNBR ECHO @###
Display the most recent Friday's day number (including
today if it's Friday):
DAYNBR /D5 ECHO @###
Display the day number for next Saturday (not including
today if it's Saturday):
DAYNBR /+7 /D6 ECHO @### or
DAYNBR /D6 /+7 ECHO @###
Display the occurring Sunday (today, if it's Sunday). In
other words, pick Sunday from a 7-day window BEGINNING
today, or slid the normal day-of-week window forware 6
days, then pick Sunday:
DAYNBR /+6 /D0 ECHO @###
This one's cute. Display today's day number and the day
number for a week ago.
DAYNBR DAYNBR /-7 ECHO @### @@###
Here DAYNBR edits today's day number into the first pattern
and removes one at sign from the second pattern. It then
invokes itself and edits the only remaining pattern using
the /-7 switch for a week ago.
Each recursive invocation of DAYNBR places another copy of
COMMAND.CON and DAYNBR.COM in memory. The only limit is
the amount of memory you have available.
Here's a real world example. The Fido node list is created
each Friday and distributed on Saturday in an ARC file
named NODELIST.Ann, where nn is the last two digits of
Friday's day number. If today is Friday, you will not have
received today's node list yet, so unpack the most recent
node list:
DAYNBR /-1 /D5 ARC E NODELIST.@A## NODELIST.@###
-----
Revision History
V1.0 10/27/85 - Basic release.