Opentopia Directory Encyclopedia Tools

4DOS

Encyclopedia : 4 : 4D : 4DO : 4DOS


4DOS is a command line interpreter by JP Software, designed to replace the default command interpreter COMMAND.COM in DOS and Windows 95/98/Me. Related products that substitute for Windows NT's command interpreter (4NT) and IBM's OS/2 command interpreter (4OS2) are also available. 4DOS was written by Rex Conn and Tom Rawson; it was first released in 1989.

Features

4DOS features a number of enhancements when compared to COMMAND.COM:

History and current status

Originally distributed as shareware, the now obsolete 4DOS has been released as unsupported freeware. The last update was version 7.50.130, released in August 2004. During its 15-year history, 4DOS underwent numerous updates; here are a few of the most significant.

Version Released New features
2.00 February 15 1989 Original release. Improved command-line editing, filename completion, command history, aliases, improved wildcards, online help, internal variables, swapping to disk or EMS, file descriptions, command separator, key stacker
2.20 July 5 1989 Executable extensions
3.00 March 7 1990 BTM batch files (cached to memory for speed), XMS swapping, variable functions, bracket variable-name syntax
4.00 November 1 1991 Colored directory listings, 4DOS.INI configuration file, include lists, command groups, implied CDD, DOS 5 UMB support
5.00 November 23 1993 Date, time, and size ranges; compressed batch files
5.51 August 22 1995 Long filename support, REXX in .BAT and .BTM files
6.00 July 24 1997 Extended directory searches, interactive configuration (OPTION command), exclusion ranges, interactive batch file debugger
7.00 June 18 2001 @file lists (as in DR-DOS)
7.50 February 24 2003 User-defined functions

Some versions of the Norton Utilities for DOS included modified copies of 4DOS called NDOS. The last version of NDOS was bundled with Norton Utilities 8, and corresponded to 4DOS 4.03.

4DOS startup

As a DOS command shell intended to replace the default COMMAND.COM, 4DOS is typically installed via a SHELL directive in CONFIG.SYS. However, it can also be launched by any method used to run executable programs: typing its filename at a command line or in the Windows Start/Run dialog, double-clicking on a Windows shortcut icon, and so on. See the Allenware guide listed under External links for one approach to using 4DOS as a secondary shell, and as an external helper for COMMAND.COM batch files.

4DOS may be passed various switches (options) in its command tail. Most of COMMAND.COM's startup switches are supported, including /P (primary shell), /E: (environment size), and /C and /K (execute a command.) There are also several new options, most notably @filename to specify the location of the .INI file and //directive to process an .INI directive as if it were present in the .INI file.

Most of 4DOS's configuration is stored in an .INI file. There are well over 100 directives available, controlling everything from display colors and key bindings to technical details of memory allocation. This file is named 4DOS.INI by default, and is usually in the same directory as the 4DOS.COM binary. Three sections are significant: [4DOS] applies to all instances of 4DOS, [Primary] applies only to the first instance of 4DOS loaded into memory, and [Secondary] only to other instances. Sections other than [4DOS], [Primary] and [Secondary] are ignored.

After the .INI file is processed 4DOS looks for a startup batch file, typically named 4START.BTM or 4START.BAT and in the same location as 4DOS.COM, and runs it if found. This file corresponds, more or less, to the .bashrc script used by bash. (4DOS can also run a 4EXIT.BTM or 4EXIT.BAT batch file when it exits, making it possible to automatically save the command history or the directory history to a file on exit and reload it on the next run.) If 4DOS is the primary shell (i.e. started with the /P switch), AUTOEXEC.BAT will be run after any 4START. The names and locations of all these automatically-run batch files may be redefined via .INI directives.

Internal commands

These are the internal commands provided by 4DOS 7.50, with a brief description of what each is used for. Commands are not case-sensitive.

File management and directory navigation

d
dirname\
(directory name ending with a backslash) Make the specified directory current; implied CDD
ATTRIB
Display or change file and directory attributes
CD or CHDIR
Display or change the current working directory
CDD
Change current drive and directory
COPY
Copy files and directories
DEL or ERASE
Delete files
DESCRIBE
Change file descriptions
DIR
List files and subdirectories
DIRHISTORY
Display or change the directory history
DIRS
Display the directory stack
EXCEPT
Temporarily hide files from another command
FFIND
Find files
FREE
Display free space on drives
GLOBAL
Recursively visit subdirectories for the benefit of an external command
HEAD
Display the specified number of lines from the start of a text file
LIST
Display a text file
MD or MKDIR
Create subdirectories
MOVE
Move files from one location to another
POPD
Restore a saved drive and directory from the directory stack
PUSHD
Save the current drive and directory on a stack; optionally change directories
RD or RMDIR
Remove subdirectories
REN or RENAME
Rename files or subdirectories
SELECT
Interactively select files for another command
TAIL
Display the specified number of lines from the end of a text file
TOUCH
Change date and time stamps of files
TREE
Display a subdirectory hierarchy
TRUENAME
Display a canonicalized filename, resolving JOIN and SUBST, network drive mappings, etc.
TYPE
Dump text files to standard output
VOL
Display volume labels

Input, output, and user interaction

BEEP
Make a sound
CLS
Clear the screen
COLOR
Change the display colors
DELAY
Pause for a specified time
DRAWBOX
Draw a rectangle
DRAWHLINE
Draw a horizontal line
DRAWVLINE
Draw a vertical line
ECHO
Output text to standard output; display or change command echoing
ECHOERR
Output text to standard error
ECHOS
Output text to standard output without appending an end-of-line
ECHOSERR
Output text to standard error without appending an end-of-line
HEAD
Display the specified number of lines from the start of a text file
INKEY
Accept a keystroke from the user
INPUT
Accept a string from the user
LIST
Display a text file
PAUSE
Wait for a keystroke from the user
SCREEN
Position the screen cursor, and optionally display a message
SCRPUT
Display a message on screen with a specific location and color
SELECT
Interactively select files for another command
TAIL
Display the specified number of lines from the end of a text file
TEE
Split standard input to standard output and a file
TEXT
Display a block of lines in a batch file
TYPE
Dump text files to standard output
Y
Combine standard input and files to standard output

Conditional and flow-control commands

label
?
List internal commands, or prompt before executing a command
CALL
Start another batch file like a subroutine; resume after the CALL when it exits
CANCEL
Abort all batch file processing
DO
Multiline loop structure for batch files
EXIT
Terminate the current shell, unless it is the primary shell
FOR
Single-line loop structure
GOSUB
Execute a labelled subroutine within a batch file
GOTO
Jump to a label within a batch file
IF
Execute a command conditionally
IFF
Execute a block of commands conditionally
ON
Enable or disable error handling in a batch file
QUIT
End processing of the current batch file
REM
Disregard the remainder of the line as a remark or comment
RETURN
End a subroutine, and continue with the command after GOSUB
SWITCH
Execute a block of lines according to the value of an expression

Other commands

?
List internal commands, or prompt before executing a command
ALIAS
Define or list aliases
BREAK
Show or change DOS Control-C and Control-Break checking status
CHCP
Display or change the current DOS code page
CTTY
Change the DOS console device
DATE
Display or change the system date
ESET
Edit the contents of an environment variable
FUNCTION
Create or list user-defined functions
HISTORY
Display or change the command history
HELP
Launch the online help system
KEYBD
Display or change the keyboard toggles
KEYSTACK
Stack keystrokes for use by another program
LFNFOR
Enable or disable return of long filenames in FOR
LH or LOADHIGH
Load a program into upper memory
LOADBTM
Control caching of batch files to memory
LOCK and UNLOCK
Enable and disable low-level drive access in Windows 95/98/Me
LOG
Control logging of commands to a text file
MEMORY
Display usage of DOS memory
OPTION
Interactively configure 4DOS
PATH
Display or change the search path
PROMPT
Change the command prompt
REBOOT
Restart the computer
SET
Display or change environment variables
SETDOS
Change various configuration settings
SETLOCAL and ENDLOCAL
Save and restore the environment, aliases, current directory, and other settings
SHIFT
Step through batch file parameters
START
(OS/2 only) Execute a command in another session
SWAPPING
Display or change 4DOS disk/memory swapping setup
TIME
Display or change the system time
TIMER
Control or display 4DOS internal timers
UNALIAS
Undefine command aliases
UNFUNCTION
Undefine user functions
UNSET
Undefine environment variables
VER
Display version strings for 4DOS and DOS
VERIFY
Display or change the DOS write-verify flag
VSCRPUT
Display text vertically
WHICH
Display location of a command

Variables

Environment variables

A copy of the environment is inherited by all programs started from 4DOS, including new instances of 4DOS. In a batch file, the environment may be saved and restored using the SETLOCAL and ENDLOCAL commands.

Environment variable names should preferentially be composed only of alphanumerics, underscores, and dollar signs, and should not begin with a digit. Other names are possible using the bracket syntax, below.

Environment variables are referenced by enclosing the variable name in percent signs: echo %colordir% The closing percent sign may be omitted if this does not create an ambiguity for the parser. Strange variable names containing troublesome characters or nested variables may be referenced by putting the variable name in brackets with no closing percent sign:

set 4dos dir=c:\bin\4dos\
set index=2
set var_2=Data
echo 4DOS DIR is %[4dos dir]
echo VAR_%index is %[var_%index]

The following environment variables have special significance to 4DOS:

_CDPATH , CDPATH
Used for directory searches (checked in this order)
CMDLINE
Contains the current command line
COLORDIR
Used for directory colorization (overrides .INI directive)
COMSPEC
Complete pathname of the current shell
DOSHELP
Pathname of external DOS help utility
FILECOMPLETION
Used for filename completion
LOGINNAME
User name
PATH
Search path
PATHEXT
Extension search order
PROMPT
Used to display the interactive prompt
TEMP4DOS, TEMP, TMP
Used for temporary and pipe files (checked in this order)
TITLEPROMPT
Used to customize the title bar in Windows 95/98/Me

Internal variables

4DOS implements over 60 internal variables, which are referenced like environment variables (with a leading percent sign) but are not stored in the environment block. Like environment variables, internal variables are evaluated before the command is executed, so they may be used with external commands as well as internal commands. The following list is not complete.

%?
Return code of the last external program
%_?
Return code of the last internal command
%+
Current command separator character
%=
Current syntactic escape character
%_4VER
4DOS version
%_ALIAS
Free alias space (bytes)
%_ANSI
ANSI driver detected?
%_BATCHLINE
Line number in the current batch file
%_BATCHNAME
Complete filename of the current batch file
%_BG
Background color under the cursor
%_BOOT
Drive from which DOS was booted
%_COLUMN
Current cursor horizontal position
%_CPU
Processor type
%_CWD
Current drive and directory
%_CWP
Current directory
%_DATE
Current date, in the local date format
%_DISK
Current drive letter
%_DOSVER
Returns the DOS version
%_ENV
Free environment space (bytes)
%_FG
Foreground color at the cursor
%_ISODATE
Current date in ISO format
%_LASTDISK
DOS LASTDRIVE value
%_MOUSE
Mouse driver detected?
%_ROW
Current cursor vertical position
%_SHELL
Shell nesting level
%_TIME
Current time, in the local time format
%_WIN
Microsoft Windows detected?

Variable functions

Variable functions are referenced much like internal or environment variables, with a leading percent sign. Unlike variables, however, they take one or more arguments, somewhat like functions in a programming language. Variable function arguments are enclosed in square brackets. Variable functions are expanded before the command is executed, so they can be used with both internal and external commands. 4DOS supports over 100 variable functions; the following list is not complete.

%@ASCII[string]
Returns values of characters
%@ATTRIB[filename]
Return a file's attributes
%@CDROM[d
]
%@CHAR[n]
ASCII character with value n
%@CRC32[filename]
Computes CRC32 checksum
%@DATE[date]
Converts a calendar date to a DOS day number, January 1, 1980 being 0.
%@DEC[n]
Returns n minus 1
%@DISKFREE[d
,b|k|m]
%@DOW[date]
Returns the day of the week for a given date
%@EVAL[expression]
Value of a numerical expression
%@EXECSTR[command]
Execute a command and return the first line of its output
%@EXT[filename]
Returns the extension of a filename
%@FILECLOSE[handle]
Close a file handle
%@FILEDATE[filename]
Returns a file's date stamp
%@FILEOPEN[filename,mode]
Open a file, return a handle
%@FILEREAD[handle,length]
Reads data from a file
%@FILESIZE[filename,b|k|m]
Returns a file's size in bytes/kilobytes/megabytes
%@FILETIME[filename]
Returns a file's time stamp
%@FILEWRITE[handle,text]
Writes text to a file
%@IF[condition,true-string,false-string]
Evaluate a condition and return one of two strings
%@INC[n]
Returns n plus 1
%@LABEL[d
]
%@LEFT[n,string]
Leftmost n characters of string
%@LEN[string]
Returns the length of string
%@LOWER[string]
Converts string to lowercase
%@MAKEDATE[n]
Returns a calendar date for DOS day number n, where 0 is January 1, 1980.
%@RANDOM[min,max]
A random integer between min and max
%@READY[d
]
%@RIGHT[n,string]
Rightmost n characters of string
%@SFN[longname]
Returns the 8.3 filename for a Windows 95/98/ME long filename
%@SUBSTR[string,start,length]
Returns a substring
%@TRIM[string]
Strips leading and trailing whitespace
%@UPPER[string]
Converts string to uppercase

Other variable types

Batch file arguments are referenced as %1, %2, %3... through %255. %# contains the number of arguments passed to the batch file. %n& contains the nth through the last arguments; %& alone contains all arguments. These may be shifted down via the SHIFT command, as in COMMAND.COM. %0 is the name of the current batch file as it was invoked.

Arguments to an alias are referenced in the same way: %1 through %255 for individual arguments to an alias, %# for the number of arguments, %n& for the nth through the last, %& for all arguments, and %0 for the name of the alias itself. SHIFT does not affect alias arguments.

The index to a FOR command is not stored in the environment; it is a different type of variable. (DO, however, does store its index in the environment.)

Redirection, piping and conditionals

command < filename
Redirect standard input from a file or device
command > filename
Redirect standard output, overwriting target file if it exists.
command >> filename
Redirect standard output, appending to target file if it exists.
command >& filename
Redirects standard output and standard error, overwriting the target file if it exists.
command >>& filename
Redirects standard output and standard error, appending to the target file if it exists.
command >&> filename
Redirect standard error, overwriting target file if it exists.
command >>&> filename
Redirect standard error, appending to the target file if it exists.
An exclamation point may be appended to any of the output redirection operators to override NoClobber support.


command1 | command2
Pipe standard output from command1 to standard input of command2
command1 |& command2
Pipe standard output and standard error from command1 to standard input of command2

command1 && command2
Execute command2 if command1 returns exit code 0 (success)
command1 || command2
Execute command2 if command1 returns a non-zero exit code (failure)
DOS being a single-tasking operating system, 'piping' is achieved by running commands sequentially, redirecting to and from a temporary file.

Other syntactical elements

^
The default command separator is a caret. The command separator can be redefined via the CommandSep directive. It may be referenced symbolically by the %+ internal variable.
( )
Parentheses can be used to group commands into a logical unit. This is useful with 'prefix' commands like FOR, GLOBAL or IF, and for redirecting to or from a group of commands.
Ctrl-X
This is the default syntactic escape character, used to disable any special meaning of the following character. The escape character can be redefined using the EscapeChar directive, and is referenced symbolically by the %= internal variable. (Ctrl-X typically displays as an up-arrow, .)
" "
Double quotes enclose arguments containing spaces and certain other troublesome characters. They are commonly used around filenames.
` `
Backquotes disable nearly all parsing of their contents. They are removed from the command line before the command is executed. Backquotes are often used when defining aliases.
;
The semicolon can be used to combine multiple filenames, possibly containing wildcards, matching files in one common directory. This is called an include list and works something like the alternation operator in regular expressions.
@
An at sign at the start of the command line prevents it from being saved in the command history or the CMDLINE environment variable, or (in a batch file) from being echoed to the screen.
*
An asterisk before a command prevents it from being interpreted as an alias.

Default key bindings

Keys may be rebound via .INI directives. This list is not complete.

Return
Execute the current command line
Esc
Cancel the entire line
F1
Help for the word at the start of the command line
Ctrl-F1
Help for the word at the cursor
Left, Right
Move the cursor one character left/right
Ctrl-Left, Ctrl-Right
Move the cursor one word left/right
Home, End
Move the cursor to the start/end of the command line
Ins
Toggle between insert and overstrike mode
Del
Delete the character under the cursor
Backspace
Delete the character to the left of the cursor
Ctrl-L, Ctrl-R
Delete the word to the left/right of the cursor
Ctrl-V
Insert the first line from the Windows clipboard
Ctrl-K
Move the entire command line to the end of the command history buffer
Up, Down
Search backward/forward through the command history
PgUp, PgDown
Open the command history window
Tab
Perform filename completion
Shift-Tab
Reverse through previous matches provided by Tab
Ctrl-A
Toggle a completed filename between short and long formats (Windows 95/98/Me)
Ctrl-Tab
Open the filename completion window
Ctrl-PgUp, Ctrl-PgDown
Open the directory history window
Ctrl-F
Expand any aliases on the command line
Alt-255
Editing escape, disables any special functionality of the following keystroke

External links

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: