Programming Field

Append - DOS/Command Prompt Reference

[Windows 95 or later] This command is removed. (Windows NT series may contain this command as a part of old DOS commands.)

* Do not use this command with Windows or the Windows Setup program.

Treats files in the specified directory as if they exist in the current directory. The added directory is referred to as an ‘appended directory’.

Syntax

append [<path>[;<path2>...]] [/X[:ON | :OFF]] [/PATH:ON | /PATH:OFF]
append[.exe] /E [/X[:ON | :OFF]] [/PATH:ON | /PATH:OFF]

Options

<path>[;<path2>...]

Specify the paths of the directories to be set as appended directories. You can specify multiple paths separated by semicolons ‘;’. Directories can be specified with relative paths or without drive letters. In such cases, the paths are completed based on the current directory, so the reference location changes whenever the current directory changes.

It will overwrite the existing appended directories if they are already set.

Also, specifying only the semicolon ‘;’ as a single character allows you to remove the current appended directories (make it empty).

/X[:ON | :OFF]

Specifies whether to make files in appended directories executable. If ‘/X’ or ‘/X:ON’ is specified, similar to specifying a directory in the Path, the search path for the execution of programs will include appended directories if the path is omitted. (Uses ‘/X:OFF’ to disable this setting.)

If executed without specifying <path>, it changes the setting for executability without modifying appended directories.

By default, it is in the state of ‘/X:OFF’.

* If Append is installed, even if you remove the settings of appended directories, the settings through this switch will still be retained.

/PATH:ON | /PATH:OFF

Configures whether to apply appended directories to the file on the resolved path when the search source file name contains a path when searching for files using appended directories.

By default, it is in the state of ‘/PATH:ON’.

/E

Ensures that the settings of ‘appended directories’ through Append are stored in the environment variable ‘APPEND’. Additionally, if the environment variable ‘APPEND’ already has a value set, it will be configured as the appended directories.

The ‘/E’ switch can only be specified during the initial execution of Append (when installing it as a resident program). Additionally, when using ‘/E’, specifying <path> is not allowed and will be ignored.

If Append has been executed before, running Append without specifying any options will output the current appended directories.

* Once executed, Append operates as a resident program. After installing, you need to execute Append like an internal command (i.e. without specifying the extension ‘.exe’). If you try to run ‘append.exe’ with the extension, you will receive an error stating ‘Already installed’.

* Since Append is a resident program, you can use Loadhigh to load it into upper memory.

Details

Using the Append program allows you to target ‘appended directories’ as the path search location when working with files. Normally you set up appended directories with Append and then use files in that state (with Append installed).

Search path with appended directories

When Append is installed (resident), it will influence certain file-related processes in MS-DOS system calls, incorporating appended directories into the file search path.

When appended directories are enabled, the search for the target file name occurs in the following order: ‘resolved path → each path in appended directories’ (after resolving the path based on the current directory). The first found file in this search sequence will be used.

  • If the current directory is ‘C:\APPS’, appended directories are ‘D:\HOME;D:\BACKUP’, the target file name is ‘NOTE.TXT’, and ‘/PATH:ON’:
    → It will be searched in the following order: ‘C:\APPS\NOTE.TXT’, ‘D:\HOME\NOTE.TXT’, and ‘D:\BACKUP\NOTE.TXT’.
  • If the current directory is ‘C:\APPS\TEST’, appended directories are ‘D:\HOME;D:\BACKUP’, the target file name is ‘..\RESULT.LOG’, and ‘/PATH:ON’:
    → It will be searched in the following order: ‘C:\APPS\RESULT.LOG’, ‘D:\HOME\RESULT.LOG’, and ‘D:\BACKUP\RESULT.LOG’.
  • If the current directory is ‘C:\APPS’, appended directories are ‘D:\HOME;D:\BACKUP’, the target file name is ‘E:\ANOTHER.DAT’, and ‘/PATH:ON’:
    → It will be searched in the following order: ‘E:\ANOTHER.DAT’, ‘D:\HOME\ANOTHER.DAT’, and ‘D:\BACKUP\ANOTHER.DAT’.
  • If the current directory is ‘C:\APPS’, appended directories are ‘D:\HOME;D:\BACKUP’, the target file name is ‘E:\ANOTHER.DAT’, and ‘/PATH:OFF’:
    → Since the path is included, appended directories will not be used, and only ‘E:\ANOTHER.DAT’ will be searched.

* ‘Resolving the path based on the current directory’ refers to the conversion that occurs when the target file name includes a relative or absolute path. In this process, the combination of the ‘current directory’ and the ‘relative or absolute path’ is used to create an absolute path. Please refer to the specific examples in the previous search scenarios.

Additionally, when "/X:ON" is set, appended directories are used in the search path during program execution. The order is as follows: ‘resolved path → each path in appended directories → each path in the PATH environment variable’. Please note that appended directories take precedence over PATH.

Appended directories and commands

Some commands always do not utilize appended directories. The confirmed commands include the following:

In addition to these, there is a possibility that appended directories may not be used in commands that directly manipulate files.

Also, when enumerating files in a directory using commands such as the Dir command, files in appended directories will not be added to the enumeration.

Appended directories and writing files

Appended directories are used during file reading or execution (/X:ON), but they are not utilized during file creation. Therefore, when opening a file from appended directories in an editor and attempting to save it directly, the file may be saved in the current directory (or strictly speaking, the resolved path). This behavior depends on the editor and, particularly, if the editor performs operations like ‘writing to a temporary file, deleting the original file, and then moving it’, the file may be saved in a location other than appended directories. When using appended directories for processes that involve writing, it is advisable to use it only with programs that do not create temporary files as part of their operations.

MS-DOS system calls (INT 21H interruption) using appended directories

In detail, when Append is embedded, the following MS-DOS system calls start utilizing appended directories:

  • 0FH - open an existing file
  • 23H - retrieve the file size
  • 3DH - open an existing file with a handle

‘16H create a file (or truncate to size 0)’, among others, is exempt from this, leading to the behavior mentioned earlier where ‘appended directories are not utilized’ during file writing operations.

Additionally, when ‘/X:ON’ is set, the following MS-DOS system calls also start using appended directories:

  • 11H - find the first file
  • 4BH - execute a program
  • 4EH - find the first file with retrieving additional information

Loading Append and /E option

Append becomes resident in the system during its initial execution, and subsequent calls to ‘Append’ utilize the resident Append program for processing. Since it is purely resident, the configuration settings are lost when the system is reset (rebooted).

When using the "/E" switch for resident mode, Append starts saving appended directories to the environment variable ‘APPEND’. However, since this is still just an environment variable, the configuration settings are lost when the system is reset. Nevertheless, using the environment variable allows you to retrieve the appended directories setting values, making them visible in listings with commands like Set and available for environment variable expansion using the ‘%’ character.

* If installed with the ‘/E’ option, you can also modify appended directories by overwriting the ‘APPEND’ environment variable using the Set command. Additionally, if the ‘APPEND’ environment variable is set before installing with the ‘/E’ option, the value becomes the appended directories when installed.

Samples

Sample 1

append c:\data;d:\data

Sets ‘C:\DATA’ and ‘D:\DATA’ as appended directories, allowing files directly under these directories to be referenced without specifying a pathname.

Sample 2

(Executing before loading Append)

set APPEND=D:\Bin
append /E /X:ON

Sets ‘D:\Bin’ as an appended directory, enabling the execution of programs in that directory without specifying a path. Additionally, uses the environment variable ‘APPEND’ for the configuration of appended directories.

See also