ALIAS
This page was last modified 12:19, 1 June 2020 by Gdx. Based on work by Mars2000you and Pfaffa.

Contents

Effect

Displays, sets, modifies, removes, saves or loads aliases to replace a command or link a file extension to a command.

Notes:

  • Each defined alias or extension is stored in the 14kB alias memory. A "Not enough memory" error message will be displayed when this memory is full.
  • The defined aliases or extensions that are present in the alias memory can be disabled by using SET ALIAS OFF.
  • Since COMMAND2.COM 2.41, a special alias UNKNOWN_CMD has been added. This alias is not displayed with the ALIAS command, but only executed when an "Unrecognized command" error occurs. If a specified alias or extension does not exist, then the error is generated. Make sure that the alias or extension itself does not raise an "Unrecognized command" error, otherwise an unbreakable loop is entered.

Syntaxes

  • ALIAS <<AliasName> = <Device>:\<Path>\<CommandName>
  • ALIAS .<FilenameExtension> = <Device>:\<Path>\<CommandName>
  • ALIAS /P|/R
  • ALIAS /S|/L <Device>:\<Path>\<AliasList>

Notes:

  • Character backslash (\) serves as a separator between the folders and the file name in MSX-DOS2. You don't have to put it after the colon of the device name. Backslash is replaced by the character yen (¥) on Japanese MSX or the character won (₩) on Korean MSX.
  • 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, the ALIAS command will display all currently defined aliases or filename extensions and their current values.

<AliasName> is a name of your choice that will run the specified command when entered. It can consist of any character except for a space character.

<FilenameExtension> is the filename extension to link. The name of such an special alias must be preceded by a period.

If just a <AliasName> or <FilenameExtension> is given, then the current value of the specified alias or extension will be displayed.

If the <AliasName> or <FilenameExtension> is followed by a non-space separator, then the separator is ignored and the name or extension is set to the following value.

<Device> is the name for used device. It can only be a disk drive.

If you don't specify the drive, the computer will delete file(s) on the currently active drive (by default, it's drive A:)

Device type Device name Remark
Disk drive A, B, C, D, E, F, G, H A floppy disk interface can control until 2 drives.


<Path> is used to specify the location in folders of command or file to link. Each folder name in path are separate by a backslash (\).

<CommandName> is the command or batch file to execute when a file with the same <FilenameExtension> or a <AliasName> is entered depending on whether you specified an extension or an alias.

When the specified .COM, .BAT or .BTM file is not found in the current directory, then the directories specified by the PATH environment variable are searched. If the file is found in one of these directories, then the complete pathname is added to the alias value. When no extension is given for this file , then the first file found that has an executable extension, is executed.

The <CommandName> has the syntax of a value defined after the separator (generally the character =). It's simply a string of arbitrary characters. No processing is performed on the characters and so the casing of characters is preserved. If the value is blank (i.e. not given) then the alias or extension is deleted from the alias memory.

When the value contains special processing characters (such as % @ < > | ^ ' "), you need to enclose it in either single (') or double (") quote characters.

Any parameters passed to a normal alias command are ignored. When parameters needs to be passed, the value must contain a  %n. Whenever a %n is encounterd, it will be replaced by the nth command.

Several commands can be associated if you separe them with the ^ character.

if you use an existing command as alias, for example to extend it, the alias will have priority on the normal command. In this case, the normal command needs to be preceded by @ if you don't want to use the alias command.

If you use special aliases linking to a file, any parameters specified after the executable filename, including the filename itself, are automatically added to the alias value, this contrary to normal aliases.

<AliasList> is the name of the file containing a series of defined aliases or extensions. It needs to be specified with the /S and /L options. If the specified file with the /L option is not an alias file, then an "Invalid filename" error message will be displayed.

/P is used to allow a pause at the bottom of the screen until a key is pressed. It can be useful to use this option when you want to display a long list of defined aliases or extensions.

/R is used to remove all currently set aliases or extensions from the alias list in memory.

/S is used to save all currently set aliases or extensions in a specified file (for example ALIAS.DAT).

/L is used to load defined aliases or extensions from a specified file into the alias memory. Note that this action will remove all existing aliases or extensions from the memory.

Examples

A>ALIAS D = DIR
A>ALIAS /S A:\ALIAS.DAT
A>ALIAS /L A:\ALIAS.DAT

Example to list only the *.BAT files in the current active directory:

A>ALIAS D = "DIR %2"
A>D *.COM *.BAT

Example to define an alias then produce a beep:

A>ALIAS DAL = DEL *.* ^ BEEP

Example with two commands for one alias:

A>ALIAS DAL = 'DEL *.* ^ BEEP'

Example with DIR expanded as alias (normal DIR becomes @DIR):

A>ALIAS DIR = "DIR %& /W"

After the line below is executed you can view a text with FQV by entering only its name and its extension (eg README.TXT):

A>ALIAS .TXT = A:\UTILS\FQV

Related to

ALIAS (Environment Variable), SET

Compatibility

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