FULLSCREEN CONTENTS Project Home Page
.TOPIC.......: How To Put Fdate Output Into An Environment Variable
.ALIAS.......: env_var
.DISCUSSION..:
CALL A BATCH FILE
=================

The most basic way to put Fdate's output into an environment variable, although not the most convenient, is to:

Since CALL first appeared in DOS 3.3, you will need DOS 3.3 or greater to use this technique.

Fdate /Ff /Atoday /O"mn zd, ccyy" /P"@SET Fdate=" >JUNKTEMP.BAT
call JUNKTEMP.BAT
del JUNKTEMP.BAT



USE AN ENVIRONMENT-MANIPULATION UTILITY
=======================================

There are shareware and public domain utilities that are written specifically to manipulate environment variables, and do that job very well. Fdate's output can be put into an environment variable by piping it to one of these utilities. When piping Fdate output to a utility, you can prevent the output from being ECHOed to the screen by redirecting the output to NUL.

Of these utilities, I can especially recommend Bob Stephan's GET (because it is very inexpensive and very powerful and flexible) and PC Magazine's STRINGS (free to ZiffNet members). See the EXAMPLES section for examples of how to use STRINGS and GET to put Fdate's output into an environment variable.

As of March 14, 1994, the current version of GET is 2.6. On CompuServe, use IBMFF to look for GET25.ZIP (which contains version 2.5 and the full documentation file) and GET26u.ZIP (the version 2.6 update of GET, which contains version 2.6 of GET, but not the full documentation). Look in CIS:IBMSYS, Library 1, or for GET.ZIP in ZNT:UTILFORUM, lib 16. GET is also available from the Public Software Library in Houston.

As of February 14, 1992, the current version of STRINGS is 1.3. On CompuServe, look for STRING.ZIP in the PC Magazine Utilities Lib of ZNT:UTILFORUM. STRHYP.ZIP contains good hypertext documentation on STRINGS.

Fdate's /V PARAMETER
====================

Manipulating the environment is an incredibly tricky business. There are questions of the local versus master environment, the version of DOS you are running, and the environment under which you are running (DOS, Windows, QuarterDeck, Carousel). In order to keep Fdate focussed on date-related issues, versions of Fdate prior to 6.1 did not attempt to put output directly into an environment variable. Instead, Fdate's output was written to standard output, that is, it was displayed on the screen. Output could then be redirected to a batch file, or piped to a utility (such as STRINGS or GET), that would put the output into an environment variable.

Starting with version 6.1, Fdate supports a /V (environment variable) parameter. A user can use /V to tell Fdate to put its output directly into an environment variable in the "parent" environment.

NOTE that due to the complexities of manipulating the environment, there may be circumstances where /V doesn't work. These include running Fdate when you have shelled out to DOS from another program, have put the command processor in upper memory (UMB) (see below), are running under Carousel, etc. In such cases, you may be able to use one of the more basic techniques described above. For a list of environments in which the /V option has been reported as NOT working, see the next section.

/Vevar tells Fdate to put output into an environmental variable whose name is "evar". For example:

Fdate /Ff /Vdate1

will set the environment variable DATE1 to the current date. If you type SET at the DOS prompt, you should see something like:

DATE1=Friday February 14, 1992

If you specify /V without an evar name, the evar name defaults to Fdate.

Example : Fdate /Ff /V
produces: Fdate=Friday February 14, 1992

If you do not use /V, Fdate output is written to standard output, i.e. to the screen.

see WINDOWS_USE Problem - /V Does Not Work Under Win3X Or Win9X
see WINDOWS_USE Problem - /V Does Not Work Under NT