About Environment Variables

Prev Next Home Home Table Of Contents Index

ABOUT ENVIRONMENT VARIABLES

I've been talking a lot about environment variables. Some of you out there in novice land don't know what an environment variable is. Many others don't know the intricate secrets handed down from the Great DOS Masters who know all the intricate undocumented features of DOS.

Your DOS shell, COMMAND.COM owns an area of memory called the Master Environment. It contains strings in the form Name=Value. Included among those strings are your COMSPEC and your PATH. Your COMSPEC tells DOS and other programs where to find COMMAND.COM. Your PATH tells DOS and other programs what directories to search when loading programs. Another common environment variable is your PROMPT. This controls what your DOS prompt will look like.

Environment variables are commonly set using the SET command. This is done by typing SET NAME=VALUE.


Example:
SET COLOR=BLUE

So what does this actually do? Nothing, unless you have a program that reads the environment variables that is looking for one called COLOR. This way, environment variables can be used to leave messages to other programs and control how they behave.

Besides leaving messages, environment variables can be accessed by batch files. If you use %NAME% in a batch file, DOS will substitute the VALUE of the variable for the %NAME% expression. And this feature is important to MarxMenu's operation.

MarxMenu uses an environment variable called MXCMD. In the MARX.BAT file the third line is %MXCMD%. So MarxMenu controls MARX.BAT by writing values to MXCMD.

In order to do this, there must be enough room in the environment for the command to fit. That is why you need to make sure that you have a SHELL command in your CONFIG.SYS to set space for MarxMenu to use.

Now so far I've only talked about the Master Environment. That's the one that the first COMMAND.COM owns. Each program that is loaded, including TSR's, gets a copy of the Master Environment in its own environment. This is called the CURRENT Environment.

One interesting feature of the Current Environment is that it is smaller than the Master Environment. DOS only creates enough space to hold a copy of the space used in the Master Environment and a little more to store the name of the program that is running.

If one program executes another program, the environment of the parent program is called the Parent Environment. You will probably never need to deal with the Parent Environment but MarxMenu can access it in case you do.

Another environment is the SHELL ENVIRONMENT. This is the one that THEY never talk about. The one you'll never read about in any books. The one you'll never learn about in any DOS classes. This is the one your parents never mentioned.

The Shell Environment is normally the same as the Master Environment. But, if you are running more than one level of COMMAND.COM, the Shell Environment is the environment of the last COMMAND.COM in memory. This environment is the most important environment to MarxMenu.

So why load up two or more COMMAND.COM's? There are several cases where this could occur. One case is when you want to run COMMAND.COM as a program under MarxMenu. This way you can type EXIT to get back to the menu. If you do this and then run MarxMenu again, you have two levels of COMMAND.COM. In this case, the first COMMAND.COM is the Master Environment and the second COMMAND.COM is the Shell Environment.

Another place where more than one COMMAND.COM is used is if you are running Microsoft Windows 3 or DesqView. Both of these programs are able to run a DOS shell. When you do, this is a second level of COMMAND.COM.

What is important is that SET commands and %NAME% commands in batch files deal only with the Shell Environment and not the Master Environment.

MarxMenu can treat environment variables as if they were MarxMenu variables. By writing to environment variables you can store information that stays there even if you leave MarxMenu and return.


Example:
Writeln %PATH% %PATH% = 'C:\;C:\DOS;'

Prev Next Home Home Table Of Contents Index

Sponsors
Shopping
Forum
Forum
email
EMail
Index
Index
Home
Home