[comp.sys.ibm.pc] Replaceable parameters from the environment

madd@bucsb.bu.edu.UUCP (03/07/87)

In article <10279@teknowledge-vaxc.ARPA> white@teknowledge-vaxc.ARPA (Bill White) writes:
>> In article <667@ubvax.UUCP> scott@ubvax.UUCP (Scott Scheiman) writes:
>> >Last I heard, the %environment-name% mechanism (which many today have
>> >correctly posted only works within batch files) is undocumented
>> 
>> Just yank your DOS manual (not even the tech ref) and look up "batch"
>> in the index.  Sure is documented!  I don't know about dos's before
>> v2.11 (because I never met one) but everything 2.11+ has it.
>> 
>
>Well, I looked up every index reference and didn't find any mention of
>substitution for environment variables. I have DOS manuals for 2.1, 3.0,
>and 3.1, so if you could tell me what page to find it on I'd appreciate it.

OK, I got it wrong.  You should have looked up "environment".  Since
my PC-DOS manual is 150 miles from here, all the following information
came from "MS-DOS Reference Manual Version 3.10 for the Model D" which
is supplied with the Leading Edge computer.  This book is poorly
written compared to the IBM PC-DOS book, but even it has the
information if you look hard enough.

Index entry:
Environment, 5-86 - 5-89

The following is quoted from pages 5-87 and 5-88:
----------------------------------------------------------------------
COMMENTS

The _environment_ is a special buffer area in memory that contains
string commands describing the current setup of the MS-DOS command
processor (the COMMAND.COM program).  Using the SET command, you can
modify or insert strings in the environment to customize MS-DOS for
specific applications.

[deleted information about environment and use of SET command]

If you use SET with no parameters, any program can search the
environment for the current values.  This lets you use the SET command
to define replaceable parameters for use in your application programs
or batch processing files.  For example, if a batch file contains the
statement LINK %DATAFILE%, you don't have to manually edit the [batch]
file to specify the DATAFILE.  Instead, you can use the SET command
SET DATAFILE=MAILMRGE.  MS-DOS will then substitute MAILMRGE for
%DATAFILE% when you run the batch file.

The SET command is most useful if you batch file contains several
replaceable parameters.  Rather than enter them on the command line
every time you run the batch file, you enter them once.  [deleted
reference to chapter 6, "Creating Batch Files"]

----------------------------------------------------------------------
end of quotation.

Pay particular attention to the "...if a batch file contains the
statement LINK %DATAFILE% ... MS-DOS will then substitute...."
section.  Voila!  Documentation.

I seem to recall better documentation in the PC-DOS manual (hey, I had
to learn it from somewhere) but once you strip off the extraneous
garbage, even a straight MS-DOS manual has the information.  Note that
I've used documentation from Tandy (MS-DOS v2.11), Leading Edge
(MS-DOS v3.10), THE (MS-DOS v3.20), and IBM (PC-DOS v3.10 and v3.20).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   - Jim Frost * The Madd Hacker -
UUCP:  ..!harvard!bu-cs!bucsb!madd | ARPANET: madd@bucsb.bu.edu
CSNET: madd%bucsb@bu-cs            | BITNET:  cscc71c@bostonu
-------------------------------+---+------------------------------------
"Oh beer, oh beer." -- Me      |      [=(BEER) <- Bud the Beer (cheers!)