SET (MSX-DOS 2)
This page was last modified 20:27, 1 June 2020 by Mars2000you. Based on work by Gdx.

Contents

Effect

Displays, modifies, adds or removes MSX-DOS 2 / Nextor environment variables.

Notes:

  • The area of memory used for environment variables is also used for disk buffers. Thus if a 'not enough memory' error occurs when using the SET command, then it may help to reduce the number of disk buffers.
  • Since COMMAND2.COM 2.31, the environment variables can be used with other commands, especially ECHO.
  • Since COMMAND2.COM 2.40, the commands INKEY and INPUT can also be used to create new environment variables.

Syntax

SET /P <EnvironmentVariable>=<Value>

Notes:

  • All the parameters are optional.
  • Character slash (/) serves to declare an option. You can put the options after the command or behind all other parameters.

Parameters

When used without any parameter, SET will display all currently defined environment variables and their current values.

<EnvironmentVariable> is the name of a specific parameter for the MSX-DOS 2 environmment.

An environment variable can have any name chosen by the user, and can consist of the same characters that are valid in a file name. The maximum length of an environment variable name is 255 characters.

MSX-DOS 2 provides several environment variables, most of these variables are defined by default when you launch the MSX-DOS 2 system. It depends also of the commands in the AUTOEXEC.BAT and REBOOT.BAT batch files.

If just this parameter is specified, then the current value of the specified environment variable is displayed. When the specified environment variable does not has been defined or when you have removed it from the environment variable list, the MSX-DOS 2 prompt will simply go to the next line.

= is a separator that indicates you want to change the value of the specified environment variable OR delete it from the environment space.

<Value> is the new value you want to give to the specified environment variable. The value of an environment variable is simply a string of arbitrary characters up to a maximum length of 255. No processing is performed on the characters and so the casing of characters is preserved.

Since COMMAND2.COM 2.40, internal variables and internal variable functions can be part of the value corresponding to an environment variable. You must here respect the syntax that needs to be applied for these internal variables and variable functions.

If you omit the separator while specifying a value after a space, it will be accepted. For example: SET REDIR OFF is equivalent to SET REDIR=OFF

If the value is blank (ie. not given) then the environment variable is deleted from the environment space. Any environment variable that does not exist has a null value (ie. no characters). For example, SET HELP= will remove HELP from the environment variable list.

/P is used to cause the output to pause at the bottom of the screen until a key is pressed. This parameter is available only since COMMAND2.COM 2.40.

Examples

With COMMAND2.COM 2.20 and higher

A>SET 
REDIR=ON
UPPER=OFF
ECHO=OFF
PROMPT=OFF
PATH=;
TIME=12
DATE=mm-dd-yy
TEMP=A:\
HELP=A:\HELP
A>SET myvar=test
A>SET myvar
test
A>SET help
\help
A>SET help=
A>SET help
A>

With COMMAND2.COM 2.31 and higher

A>SET MyName=Alex
A>ECHO Hello %MyName%, how are you?
Hello Alex, how are you?

With COMMAND2.COM 2.40 and higher

How to extend the prompt to make display more info by using an internal variable function, for example to also show the amount of free disk space:

A:\>SET PROMPT "(%@DISKFREE[@:,k]%K) %_CWD%>"
(309K) A:\>SET PROMPT
(%@DISKFREE[@:,k]%K) %_CWD%>
(309K) A:\>

Related to

BUFFERS, ECHO, INKEY, INPUT , MSX-DOS 2 Environment Variables

Compatibility

MSX-DOS 2 / Nextor with COMMAND2.COM v2.20 and higher