Category : Batch File Utilities - mostly for DOS
Archive   : DATENV12.ZIP
Filename : DATENV.DOC

 
Output of file : DATENV.DOC contained in archive : DATENV12.ZIP































DATENV
version 1.2












Copyright (c) 1991
Jonathan Goldman






























DATENV is a small utility that will set up to three DOS
environment variables to a value corresponding to a date string.
The date is calculated from the system date and can be calculated
plus or minus or based on a specific day of the week. DATENV can
also compare the date of a file to the calculated date. The
environment variable can then be used in a batch file to name a
file or to test its date. This is probably very confusing --
here are some examples:

Batch file to rename a file to today's date:

DATENV one
RENAME AUDIT.TRL %one%.aud

If you ran this on May 15, the value 0515 would be
substituted for %one% in the rename command and
AUDIT.TRL would be named 0515.AUD.


Batch file to see if the file that was supposed to be
downloaded today really happened, or if last week's file is
still there:

DATENV one FILE download.fil
IF %onef% == SAME goto continue
goto end
:continue
echo the file really is dated today
rename download.fil %onef%dl.fil
:end

If you ran this on May 15 and the file "download.fil"
had a file date of May 15, it would be renamed
0515dl.fil.


Batch file to rename a file to Tuesday's date. If today is
Tuesday, then use today's date; otherwise use last Tuesday's
date:

DATENV two DOW tue
rename TUESDAYS.DOC %two%file.doc

If you ran this on Wednesday, May 15, TUESDAYS.DOC
would be renamed 0514FILE.DOC.






page 1














DATENV 1.2

SYNTAX options:

DATENV varname [DIF difference] [SVAR difference] [DOW dayname]
[C] [WD] [Y] [FILE filename] [ENV envtype]


Notes:
1. All options except for the varname are optional.
2. All options are case insensitive.
3. Except for the varname, which must be the first
argument, all options can be placed in any order.

varname: The environment variable name to be used.

DIF: The value by which to modify the date; can be positive
or negative.

SVAR: Sets a second variable (varname2) to a value resulting
from modifying varname's value by SVAR's argument.

DOW: The day of the week to which to set the variable. If
DOW equals today, then uses today; otherwise uses the
last day of that name.

C: Confirming flag. Will display a small entry field
asking confirmation of the date to be used and prompts
for confirmation or a new date.

FILE: The file name to use to compare file date to date
derived from program.

WD: Week day flag. Will set the variable to the day name
instead of the date.

Y: Year flag. Will include the last two digits of the
year in the variable value, with the year first,
e.g., 910515.

ENV: Method for modifying environment. See detailed
explanation in this document.


On the following pages are some examples of the uses of these
options. At the end of the listing of single argument examples
are multiple argument examples, an explanation of the evaluation
sequence, and some sample batch files.

For all examples, assume that the program was executed on
Wednesday, May 15, 1991.


page 2














DATENV 1.2


varname:

arguments: NONE - Replace with the environment variable name
to be set


Examples:

DATENV hello

would set the environment variable "HELLO" to 0515.


DATENV goodbye

would set the environment variable "GOODBYE" to 0515



----------------------------------------------------------

DIF:

arguments: a numeric value to be added (or subtracted if
negative) from the date set.


Examples:

DATENV hello DIF 1

would set "HELLO" to 0516

DATENV goodbye DIF -30

would set "GOODBYE" to 0415














page 3














DATENV 1.2

Y:

arguments: NONE - a flag to include the year in the variable


Example:

DATENV hello

would set "HELLO" to 910515

-----------------------------------------------------------------

DOW:

arguments: Day of week (SUN, MON, TUE, WED, THU, FRI, SAT).


Examples:

DATENV hello DOW mon

would set "HELLO" to 0513

DATENV goodbye DOW

would set "GOODBYE" to 0515


----------------------------------------------------------------

WD:

arguments: NONE - a flag to cause the environment variable to
be set to the English day name, e.g., MONDAY.

Example:

DATENV hello WD

would set "HELLO" to WEDNESDAY










page 4














DATENV 1.2

C:

arguments: NONE - a flag to trigger a confirming screen

Examples:

DATENV hello C

would display the following screen:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
HELLO will be set for 0515

If you wish to continue using this date, press Y.
If you wish to pick another date, press N.
Any other key will cause this program to stop.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

If the user presses "Y", the following screen is displayed:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
You pressed Y to use the data for

Wednesday, May 15, 1991

Please confirm by pressing Y again.
If you wish to pick another date press N.
Any other key will cause this program to stop.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Pressing "N" at either of the above screens will display the
following screen:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please enter the date for which you wish to use data
in the format:

mm/dd/yyyy example: 12/31/1988
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

If the user types in 5/15/91, the value will be set to May 15,
0091. This new date will then be presented for confirmation.
Pressing any key other than "Y" or "N" (not case sensitive) will
abort the program with an ERRORLEVEL which may be tested in the
calling batch file.

The confirming screen is included for use in an environment where
the users may not always run the program on the designated day or
may need to rerun it on another date.


page 5














DATENV 1.2


SVAR

arguments: A value by which to modify the second variable.

Examples:

DATENV hello SVAR -2

would set "HELLO" to 0515 and "HELLO2" to 0513

DATENV goodbye SVAR 30

would set "GOODBYE" to 0515 and "GOODBYE2" to 0614

SVAR is included to allow the removal of older files on a regular
basis. See the SAMPLE1.BAT file for an example of this use.
---------------------------------------------------------

FILE

arguments: A file name whose date stamp would be compared to
the variable value.


Examples:

DATENV hello FILE sample1.bat

would set "HELLO" to 0515 and "HELLOF" to NEWER if the
file date of SAMPLE1.BAT was later than May 15, 1991.


DATENV goodbye FILE sample1.bat

would set "GOODBYE" to 0515 and "GOODBYEF" to SAME if
the file date of SAMPLE1.BAT was May 15, 1991.

DATENV greeting FILE sample1.bat

would set "GREETING" to 0515 and "GREETINGF" to OLDER
if the file date of SAMPLE1.BAT was earlier than
May 15, 1991.








page 6














DATENV 1.2

ENV

arguments: 1 = Current shell environment -- default (and
therefore unnecessary)

2 = Master environment

3 = Create batch file with name of "varname.BAT"

Explanation:

Running a program from a secondary command shell (usually invoked
when a program "shells to DOS") will normally create a copy of
the original environment. Any modifications to that environment
are only in effect while that secondary shell is active. It is
assumed that most applications of DATENV will be run as part of a
batch file, so even if run from a secondary shell the environment
will stay the same for the duration of the batch file. For those
people who have other needs, DATENV offers two other methods for
modifying the environment.

Option 2 will alter the master environment, even if called from a
secondary shell. WARNING: These values will NOT be visible from
the current (secondary) environment.

Option 3 will create a batch file using as its name the
environment variable name. The batch file can then be "called"
from another batch file to set the environment values. This
feature might be useful if DATENV has some problems with altering
the environment on your configuration. WARNING: DATENV will
overwrite any existing batch file with the same name.

Example:

NEW.BAT:

DATENV hello ENV 3
call hello.bat
copy myfile.new AB%hello%.fil
set hello=


The above batch will run DATENV to create the batch file
"HELLO.BAT". HELLO.BAT will contain one line:

set HELLO=0515

*Please note that you must be using DOS 3.3 or greater to use the
call feature in a batch file.


page 7














DATENV 1.2

COMPOUND ARGUMENTS

All command line options may be combined in any order (and any
case). The only requirement is that the variable name be the
first argument.

Examples:

DATENV hello DIF -2 SVAR -7 Y

would set "HELLO" to 910513 and "HELLO2" to 910506


DATENV hello DIF -1 WD

would set "HELLO" to TUESDAY


DATENV hello DIF -7 FILE sample1.bat

would set "HELLO" to 0508 and "HELLOF" to SAME if the
file date of SAMPLE1.BAT is May 8, 1991.


LOGIC SEQUENCE:

1. Varname is set to today
2. If a DOW value is named, the value for Varname is set to the
last occurrence of that day. Today is the last occurrence
of today's name.
3. If a DIF value is indicated, the value for Varname is modified
by that value.
4. If the onfirm flag is set, the screen will come up with the
day that the Varname value represents.
5. If the FILE value is set, the file date is compared to the
value for Varname and an environment variable named by
appending "F" to Varname is set to LATER, SAME, or OLDER,
based on the file date relative to Varname value.
6. If SVAR is used, the date value in use for Varname is modified
by the SVAR value and a second environment value is created
by appending "2" to Varname.
7. If the flag is set, the last two digits of the year are
placed at the beginning of the date value for Varname and
SVAR.
8. If the flag is set, Varname's value is then changed to
the day name of the Varname value.





page 8














DATENV 1.2

SAMPLES: Two sample batch files are included:
=================================================================
----SAMPLE1.BAT----
This batch file will download a file using a download program
called DOWNLOAD. The file name is set for a regular Tuesday
date. The batch file also deletes the file from two weeks
earlier. Note that ERRORLEVEL is checked to make sure that
DATENV completed successfully and that the environment variable
is set to NULL after the batch completes. If the variable is not
cleared, the environment can fill.

: SAMPLE1.BAT
: An example of using DATENV.EXE for a file download from the
: command line and cleaning up an old file
DATENV one DOW tue SVAR -14
if ERRORLEVEL 1 goto bad :note this is needed to
:test for successful completion
DOWNLOAD file%one% to c:\download\*
del c:\download\file%one2%
set one=
set one2=
goto end
:bad
echo this didn't work
:END
=================================================================
----SAMPLE2.BAT----
This batch file will download a file using a communications
program that utilizes a command file. Note the use of a skeleton
file for the beginning of the commands and the use of the DOS
redirection capabilities to build a command file using
environment variables.

: SAMPLE2.BAT
: An example of using DATENV.EXE for a
: file download from a command file
DATENV one
if ERRORLEVEL 1 goto bad :note this is needed to
:test for successful completion
copy skeleton.fil comm.prg
echo DOWNLOAD file%one% to c:\download\* >> comm.prg
echo WAIT finished: >> comm.prg
echo PUT logout >> comm.prg
: this is where the comm program calls the command file
commprog comm.prg
DATENV one FILE c:\download\file%one%
if %onef% == SAME goto end
:bad
echo this didn't work
:END

page 9














DATENV 1.2

REGISTRATION:

DATENV is distributed as shareware. It is NOT in the public
domain. This means that you may use this program for 30 days to
test its function. After the 30 day test drive is finished, you
must either register DATENV or discontinue its use.

Registered owners will receive notification of any problem
reports and enhancements. Registered owners are also
automatically registered for any upgrades released within one
year of registration.

To register this program please print and fill out the
registration form on the last page. Registration fees are:

QTY Per license

1 $20.00
2 - 10 17.00
11 - 50 15.00

Add $10 if you want a disk mailed to you.
Add $30 for source code (including copies of external routines --
see Tidbits on next page)

Please contact me for quantities greater than 50 or network use.


--------------------------------------------------

PROBLEMS?

I may be reached by mail at:

Jonathan Goldman
5014 Stone Haven Drive
Annandale, VA 22003

or Compuserve E-mail at 70441,572.

You may also call me (7 PM to 9:30 PM Eastern time M-F) at
(703) 425-9431. I will not accept collect calls, but will return
calls to registered owners if I am not available.








page 10














DATENV 1.2

General Tidbits:

1. DATENV was compiled using Borland Turbo C++.

2. I would like to acknowledge the use of the following C
routines:

Date manipulation: Date functions by James Seed
Environment handling: SETENV by Richard Brittain
Command line parsing: Eric Allman modified by Peter da Silva
Master environment: David Dubois modified by Peter Thomas

3. DATENV has been tested under DOS 3.1, 3.3, and 5.0 as well as
4DOS.

--------------------------------

Possible future enhancements:

1. Modify the date on a month basis instead of days (e.g., today
minus one month).

2. Set the specific date of month ( e.g., the 15th).

3. Trigger the creation of a batch file if program can't find or
manipulate environment (e.g., new DOS version, out of
space).

If you have any other suggestions, please contact me.

-------------------
Revision history:

1.0 initial release
1.1 modified for master environment and batch file
1.2 minor correction to doc and corrected banner version number















page 11















DATENV 1.2 REGISTRATION FORM


Name: _________________________________________________


Company: _________________________________________________


Address: _________________________________________________


City: ______________________________


State: ______ ZIP: ______


Telephone: ( ) ______ - _________


Please enclose check for registration fee and mail to:

Jonathan Goldman
5014 Stone Haven Drive
Annandale, VA 22003


License fee:

QTY Per license

1 $20.00
2 - 10 17.00
11 - 50 15.00

Add $10 if you want a disk mailed to you.
Add $30 for source code (including copies of external routines --
see Tidbits).























  3 Responses to “Category : Batch File Utilities - mostly for DOS
Archive   : DATENV12.ZIP
Filename : DATENV.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/