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:

  1. Power supply will turn on.
  2. Memory check will occur (on-screen message tells you this).
  3. Floppy drive will make a whirring noise.
  4. Operating system will be loaded into memory.
  5. 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 then COMMAND.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: UNFORMAT command:

    LABEL command:

    VOLUME command: CHKDSK command: DISKCOPY command:

    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, and PROJ-2, assume that one has the following organizational scheme:

      
       \ -+- DATA
          +- PROJECTS
             |
             +- PROJ-1
             |  |
             |  +- PROJ-1.DRW
             |  
             +- PROJ-2
    
    The preceding diagram means that:

    1. The root directory (\) has two subdirectories, which are DATA and PROJECTS ;

    2. The PROJECTS directory has two subdirectories, called PROJ-1 and PROJ-2 ;

    3. PROJ-1 contains a file called PROJ-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:

    CD \PROJECTS
    DIR

    we could see the following display:
         Directory of \PROJECTS:
             .                
             ..               
             PROJ-1   < DIR >  12 Jan 97:1343
             PROJ-2   < DIR >  14 Jan 97:1537
              
    where "." 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:
    • 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; and

        c) 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".

    There are two types of files whose distinction is of primary interest to programmers:
    • 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 of old-file.

      Example: COPY test.txt test.cpy .

      Example: COPY old.dat B:\old.cpy

        will copy the file old.dat from the current drive and directory and will transfer that file to floppy drive B at the root directory (\) as the new file old.cpy .

      Example: COPY A:DR*.* B:\PROJ-1\????????.???

        will copy all files on the current directory of drive A: beginning with the letters DR to drive B:'s directory PROJ-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 by file .

      Note: The COPY command cannot be used to copy directories.

    XCOPY command:

    • XCOPY functions much like the COPY 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 and file-2 is displayed on-screen.

    RENAME command:

    • RENAME is a destructive form of the COPY command.

      Usage: RENAME old-file new-file , where

        old-file is the file to be renamed
        new-file is the new filename for old-file.

      Function: The preceding command sequence causes two operations to be executed:

        a) old-file is copied to new-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! If DEL 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 the DELETE 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 with ATTRIB 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.

    PRINT command:

    • One often wants to print a text file on the printer, which the PRINT command facilitates.

      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 dir that will

          a) exist, if the pathname dir is correct; and
          b) be subordinate to the current directory if dir does not exist prior to the execution of the MKDIR command.

      Example: MKDIR A:\PROJECTS\PROJ-2

        will make the directory PROJ-2 under the directory PROJECTS, if PROJECTS 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, if PROJ-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 of TREE.

    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 of RMDIR; and

        b) all subordinate files and directories of dir-path must be deleted prior to invoking RMDIR.

    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 (or HELP command-name , where

        command-name is the name of a DOS command.

    DATE and TIME 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 or HHMM (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:

    1. Provide low-level support for the graphical user interface and associated window managers, windows, graphics objects, etc.

    2. Support file input/output and directory assignment via one or more widgets that pop up on the screen.

    3. 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.

    4. Provide linkages for computational libraries for special math functions that may be required when computing graphics objects.

    For example, when one SAVEs 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.