DIR Does Not Work with ANSI Escape Sequence ESC[nh (32655)



The information in this article applies to:

  • Microsoft MS-DOS operating system 3.3
  • Microsoft MS-DOS operating system 4.0
  • Microsoft MS-DOS operating system 4.01
  • Microsoft MS-DOS operating system 5.0
  • Microsoft MS-DOS operating system 5.0a
  • Microsoft MS-DOS operating system 6.0
  • Microsoft MS-DOS operating system 6.2
  • Microsoft MS-DOS operating system 6.21
  • Microsoft MS-DOS operating system 6.22

This article was previously published under Q32655

SYMPTOMS

After you set the mode through ANSI escape sequences with the PROMPT command, the following occurs regardless of the particular mode chosen. When you call directory listing with the DIR command, the screen clears immediately after displaying the directory listing, so that you do not have a chance to look at the directory listing. However, if you type "prompt $p$g" (without the quotation marks) and then use the DIR command, the directory works correctly.

CAUSE

Any time you use one of the ANSI escape codes to set the screen mode, the screen is cleared. This explains why you are seeing the screen cleared after doing a DIR command.

WORKAROUND

To avoid this problem, set the screen mode in a batch file. For example, if you wanted to set the screen mode to 40x25 monochrome mode, you would insert the following text into a batch file:

echo <ESC>[0h

Depending upon your editor, you would replace <ESC> with whatever character represents ESCAPE. In EDLIN, you use ^[. And in other word processors, you use the back arrow character.

Modification Type:MajorLast Reviewed:5/12/2003
Keywords:KB32655