Intro. to Computers for Architecture Majors: § 2: DOS Fundamentals
Instructor: M.S. Schmalz
We begin our discussion of DOS with several basic definitions.
2.1. Booting the System and Types of DOS Commands.
In order to run DOS, the computer must be started, which is called booting the system. On most IBM-compatible PCs, the following procedures are used.
Definition. Cold Start is used when the computer is not powered up, or if the computer "locks up". If you have a hard disk, there should be no floppy disk in drive A, since DOS may expect a "system boot disk" to be there.
Procedure. To cold-start your computer, turn the power switch off, then on. The following events will occur:
- Power supply will turn on.
- Memory check will occur (on-screen message tells you this).
- Floppy drive will make a whirring noise.
- Operating system will be loaded into memory.
- You will get a message at your terminal, with a prompt that looks like
A: >
.
Definition. Warm Start is used when the computer is already powered up or locked up.
Definition. The warm start procedure is the same as with cold start. However, to warm-start your computer, press the
{CTRL}
,{ALT}
, and{DEL}
keys at the same time. Events 2-5, as listed above, will occur.Question. What does booting do?
Loads DOS, the operating system, into memory;
Hidden files are loaded (
O.SYS
,MSDOS.SYS
) and thenCOMMAND.COM
(the latter contains internal commands);Internal Commands stay in memory;
External Commands are executable files stored on disk;
You may need to use the DATE or TIME commands (described below) after booting.
There are several types of DOS commands, which are:
System Commands directly affect the computer system (primarily, the CPU);
File Commands primarily affect files;
Directory Commands pertain to directories of files; and
Disk Commands monitor or affect information on disk.
We discuss each of these commands, as follows.
2.2. DOS Disk Commands.
FORMAT
command, and why it is needed:
- It is useful to format new floppy disks for compatibility with your computer's disk storage system.
Function:
FORMAT
prepares a floppy disk for useNotation: DOS Disk drive specifiers:
A:
B:
(floppy disk drives);C:
,D:
, ... (hard disk drives).Options: Switches for the
FORMAT
command are:
/S
- puts DOS system files on disk, thereby making a system disk.Usage:
FORMAT [switches] drive-specifier
Procedure: To format a floppy disk:
- Insert disk in drive A:
- Type "FORMAT A:" and follow instructions.
Note: DO NOT TYPE "FORMAT C:". This can cause much trouble by erasing your hard disk.
Tasks Performed by
FORMAT
Command:
- Writes electronic guidelines on disk for addressing;
- Checks each disk sector to determine if it is bad or o.k.;
- Creates root directory that contains information about files;
- Creates File Access Table (FAT) -- keeps track of bad sectors on disk, good sectors, and used sectors, and is basically a software index to the disk contents;
- Creates and copies a boot record on the first sector of the formatted disk. It contains info about the format structure of the disk and the loading program.
UNFORMAT
command:
- You may or may not have this command on CIRCA computers
Function: Restores contents of disk to original contents (prior to formatting) ONLY if no files have been stored on the disk after the disk was formatted.
Usage:
UNFORMAT drive-spec
LABEL
command:
- In the early days of computers, labels were used to identify data stored on reels of magnetic tape.
Function: Changes a floppy disk's electronic label, which is useful for documentation purposes.
Usage:
LABEL [drive-spec] [label]
, where
[drive-spec] =
A:
,B:,
etc.[label] = a string of characters in {A-Z,0-9,"-"}.
Procedure: To change a disk label, perform the following steps:
- Insert a floppy disk in Drive
A:
;- Type
LABEL A:
- You will be prompted for a disk label. Enter
label
, as defined previously.
VOLUME
command:Function: displays the volume label of a disk referenced by a
drive-spec
.Usage:
VOL drive-spec
CHKDSK
command:
- You may occasionally want to display important disk and memory characteristics not shown by the directory display (
DIR
) command.Function:
CHKDSK
causes a disk checking program to run on the disk drive denoted bydrive-spec
.Usage:
CHKDSK drive-spec
.Options:
CHKDSK /V
allows you to view information about hidden files (ones that are concealed from the user's scrutiny).
Note: On some versions of DOS,
CHKDSK
may cause your stored data to be partially erased. Check with your operating system manual before you use this command.DISKCOPY
command:
- It is useful to copy floppy disks in their entirety, for backup purposes. However, do not use this command to "pirate" licensed software!
Function:
DISKCOPY
copies the contents of one disk drive to another.Usage:
DISKCOPY old-disk new-disk
, where
old-disk
denotes the disk data is to be copied from, and
new-disk
denotes the disk data fromold-disk
will be copied to.
Example:
DISKCOPY A: B:
copies the contents of a diskette in drive A to a diskette in drive B without destroying data in drive A.
Example:
DISKCOPY A: A:
copies the contents of a diskette in drive A to a diskette that the operating system prompts you to put into drive A after the first part of the copying operation is completed.
2.3. DOS Directory and File Commands.
In order to store information in a reliable, organized fashion, DOS provides commands that manipulate abstract structures called files and directories.
2.3.1. DOS File Structures.
Definition. Files are abstractions that are used to contain information in a manner accessible to the user. Files are usually named in a mnemonic fashion, i.e., in a manner that facilitates understanding of file contents by inspection of the file name.
Definition. Directories are high-level abstract constructs that are convenient for grouping files together.
Definition. Root Directory is the highest-level directory.
Definition. Subdirectory is any directory subordinate to (or under) the root directory.
Example. Given the root directory denoted by (\) and subdirectories called
DATA
,PROJECTS
,PROJ-1
, andPROJ-2
, assume that one has the following organizational scheme:\ -+- DATA +- PROJECTS | +- PROJ-1 | | | +- PROJ-1.DRW | +- PROJ-2The preceding diagram means that:
- The root directory (\) has two subdirectories, which are
DATA
andPROJECTS
;
- The
PROJECTS
directory has two subdirectories, calledPROJ-1
andPROJ-2
;
PROJ-1
contains a file calledPROJ-1.DRW
.
Let us look ahead briefly to the
DIR
command, which displays directory contents, to see how DOS commands can interact with this concept of directory and file structures.
Example. In the above structure, if we execute the commands: we could see the following display:
CD \PROJECTS
DIR
Directory of \PROJECTS: . .. PROJ-1 < DIR > 12 Jan 97:1343 PROJ-2 < DIR > 14 Jan 97:1537where "." and ".." denote the current and parent (higher-level) directories, respectively.
2.3.2. DOS File Naming Conventions.
DOS uses filenames, which are strings of characters that have the following attributes:There are two types of files whose distinction is of primary interest to programmers:
- Form:
name.ext
, where
a)
name
is a string of 8 legal filename characters or less taken from the set:A = { A-Z,a-z,0-9,$,&,@,!,%,-,_,(,),{,} } ,
In this class, we prefer that you use the abbreviated character set:F = { A-Z,a-z,0-9,$,-,_ } .
b) . is the period; andc)
ext
is a string of 3 legal filename characters or less, called the extension.Note: A filename may NOT contain arithmetic operators such as + and = .
Observation. File types are also specified by their extensions. Several examples follow:
.EXE
- executable file (an application program);
.COM
- executable file that can be relocated in memory;
.BAT
- a script file that the computer uses like a small program, for convenience;
.ASC
or.TXT
- text file;
.DOC
- document file produced by a word processor;
.PAS
- Pascal program (source code);
.BAS
- BASIC programming language file; and
.DRW
or.ACD
- AutoCad drawing file.
Observation. Filenames may include wildcards, which are ways of making filenaming easier when you don't know the complete file name.
Definition. The global wildcard "*" matches zero or more characters in the file name or extension.
Example. The wildcarded file name
TES*.*
denotes all files whose names start with "TES", and have any extension or no extension.Definition. The local wildcard "?" matches one and only one character in the file name or extension.
Example. The wildcarded file name
TES??.E*
denotes all files whose name has five characters and starts with TES, and has an extension that begins with "E".
- User Files or Visible Files have names that can be seen on the monitor when you execute the DIR command to display the contents of a directory.
- Hidden Files are not usually listed or accessed by users.
2.3.3. DOS File Commands.
COPY
command:
- It is often useful to make copies of files, for backup purposes. The
COPY
command helps you do this.Usage:
COPY old-file new-file
, where
old-file
is the file to be copied
new-file
is the new copy ofold-file
.Example:
COPY test.txt test.cpy
.
Example:
COPY old.dat B:\old.cpy
will copy the file
Example:old.dat
from the current drive and directory and will transfer that file to floppy drive B at the root directory (\) as the new fileold.cpy
.
COPY A:DR*.* B:\PROJ-1\????????.???
will copy all files on the current directory of drive
A:
beginning with the lettersDR
to driveB:
's directoryPROJ-1
.
Observation:
COPY CON file
is an obsolete way to create text files, since anything you type on the keyboard (device called
CON
for "console") will be redirected by the operating system to reside in the diskfile denoted byfile
.Note: The
COPY
command cannot be used to copy directories.
XCOPY
command:
XCOPY
functions much like theCOPY
command, but allows interactive selection of files, which was not found in early versions of MS-DOS.
COMP
command:
COMP
allows you to compare the contents of two files.Usage:
COMP file-1 file-2
Output: A list of differences between lines in
file-1
andfile-2
is displayed on-screen.
RENAME
command:
RENAME
is a destructive form of theCOPY
command.Usage:
RENAME old-file new-file
, where
old-file
is the file to be renamed
new-file
is the new filename forold-file
.Function: The preceding command sequence causes two operations to be executed:
a)
old-file
is copied tonew-file
, then
b)old-file
is deleted (removed from disk storage).
DELETE
command:
It is frequently useful to remove old or unused files from your disk(s), to free up space for new information.
Usage:
DEL file
deletes a file denoted by
file
from the current disk drive.
Note: Use
DEL
with care! IfDEL
is used in conjunction with a filename that has wildcards in it, then DOS may (or may not) prompt you whether or not you really want to delete all the files that match that wildcarded filename.
ERASE
command is a synonym for theDELETE
command.
ATTRIB
command:
- Occasionally, you may want to set file attributes such as READ-ONLY (to protect against deletion).
AutoCAD duplicates the function of the DOS command
ATTRIB
more reliably. Thus, we will not deal withATTRIB
in this class.
TYPE
command:
- One often wants to view the contents of a text file, which the
TYPE
command facilitates.Usage:
TYPE filename
, where
filename
is the name of a text file.Note: Don't use this command with non-text files, as it may cause your computer to lock up.
- One often wants to print a text file on the printer, which the
Usage:
PRINT filename
filename
is the name of a text file.Note: Don't use this command with non-text files, as it may cause your printer to lock up.
2.3.4. Directory Commands.
CD
command:
CD
changes the current directory.Usage:
CD dir
, where
dir
denotes the directory-path of the directory to be set as current.Example:
CD A:\PROJECTS\PROJ-1
Variants:
A:
,B:
, etc. set the current (default) disk drive.MKDIR
command:
As you build your directory structures on disk, you will want to add new directories to organize new information.
Function:
MKDIR
builds new directories in an existing directory structure.Usage:
MKDIR dir
creates a new directory
Example:dir
that will
a) exist, if the pathname
dir
is correct; and
b) be subordinate to the current directory ifdir
does not exist prior to the execution of theMKDIR
command.
MKDIR A:\PROJECTS\PROJ-2
will make the directory
PROJ-2
under the directoryPROJECTS
, ifPROJECTS
exists as a directory on drive A, under the root directory (\).Example:
MKDIR PROJ-2
will make the directory
PROJ-2
under the current (default) directory, ifPROJ-2
does not already exist under the current directory.
DIR
command:
One frequently wants to interrogate a directory on disk to see if a certain file exists, or if file contents are up to date. The
DIR
command and its various options help us to perform this task efficiently.
Function:
DIR
displays a list of the files and directories in the current directory or in a directory path that is specified in the command. File size is given in bytes or characters, together with the date and time the file was last modified.Usage:
DIR [dir-path]
, where
dir-path
is the pathname of a directory.
Options:
DIR /W
is the same as DIR, but shows the filenames and directory names only in a multi-column (Wide) display.
Options:
DIR /P
is the same as DIR, but but shows the filenames and directory names only in a paginated display that you can scroll through by pressing a key (usually the space bar or Enter key).
TREE
command:
The
TREE
command displays a hierarchical file structure starting at the current directory (highest level of the hierarchy).
Usage:
TREE dir-path
, where
the directory path
dir-path
must exist on disk prior to invocation ofTREE
.
RMDIR
command:
RMDIR
removes a directory, if it exists on disk.Usage:
RMDIR dir-path
, where
a) the directory path
dir-path
must exist prior to invocation ofRMDIR
; andb) all subordinate files and directories of
dir-path
must be deleted prior to invokingRMDIR
.2.4. DOS System Commands.
On IBM-PC compatible machines, MS-DOS provides several convenient commands that help you monitor or change the state of your computer system.
HELP
command:
- This command is new in later versions of DOS.
Function: Information pertaining to the computer or to a given command is displayed on the monitor.
Usage:
HELP
(orHELP command-name
, where
command-name is the name of a DOS command.
DATE
andTIME
commands:Function: Set the system date and time.
Usage: Enter the command, then respond to the prompt by entering the date and time as
DDMMYYYY
orHHMM
(24-hour format).CLS
command clears the monitor screen.
VER
command displays the version number of the version of DOS you are running.This concludes our brief summary of how DOS works. We next examine DOS' role in supporting applications programs.
2.5. How DOS and AutoCAD Work Together.
DOS and Windows® perform the following principal support functions for applications software:
Provide low-level support for the graphical user interface and associated window managers, windows, graphics objects, etc.
Support file input/output and directory assignment via one or more widgets that pop up on the screen.
Handle errors and exceptions that arise from the interaction of application software (and associated subordinate tools, windows, etc.) with the operating system. High-level error checking is usually provided by the application software, which customarily monitors errors that are caused by the user.
Provide linkages for computational libraries for special math functions that may be required when computing graphics objects.
For example, when one
SAVE
s a file that you've drawn in AutoCAD, the following high-level actions could occur:Step 1. The user enters or selects the filename to be saved using a file selector widget (FSW), and clicks on the
SAVE
button.
Step 2a. The FSW requests an I/O operation from the operating system (OS), which acknowledges it has received the request.
Step 2b. The OS requests an I/O operation from the CPU, which acknowledges it has received the request.
Step 2c. If the CPU is performing another task (e.g., in a multi-tasking system), then that task is suspended, and the CPU requests an I/O operation from the I/O processor (IOP). The IOP acknowledges that it has received the request, and checks to see if the requested disk drive is available.
Step 3. If the disk drive is not available, the IOP passes that information through the CPU to the OS, and thence to the applications program. The user waits until the requested resource is available. Otherwise, the IOP seizes control of the disk drive and informs the CPU (and, hence, the OS and applications program) that the requested data transfer can occur.
Step 4. The applications program passes the data to be saved to the OS, which passes the data to the CPU (and, hence, to the IOP). The IOP writes the data onto the disk at the location pointed to by the File Access Table entry.
Step 5. If the write-to-disk operation encounters an error or an exception, then that information may be passed up to the application program, and user intervention may be sought. Otherwise, the IOP notifies the CPU, which notifies the OS, which notifies the applications program that the write operation has succeeded. Additionally, the IOP modifies the FAT as required, to reflect changes in the disk or file attributes or structure. If a process was suspended by the CPU to permit the I/O operation to occur, then that process is restarted.
Similar processing sequences occur for requested computational operations, graphics operations (such as line drawing), etc.
By preserving software modularity, system developers can enhance maintenance and reliability. That is, by localizing specific operations to given software modules, it is easier to detect places in the source code where errors occur. Such errors can then be fixed at the given modular level, without having to modify the entire software system.
Additional benefits of modular design are realized in efficient replacement of components. For example, when a given component of the application software that performs a specific task (e.g., line drawing) is to be replaced, then that component (if properly designed) can be replaced by another, more capable software module. We call this process incremental upgrading.
This concludes our overview of DOS and its associated commands.
We next examine basic AutoCAD commands.