Escape sequence

From Wikipedia, the free encyclopedia

This article refers to codes used as commands for computing devices. Escape sequence can also refer to a sequence of escape characters used in parsing source code.

An escape sequence is a series of characters used to trigger some sort of command state in computers and their attached peripherals.

An escape character which is usually assigned to the Esc key on a keyboard may be used to indicate that the next sequence is a command to be executed rather than a graphic to be displayed. The Esc key may be used as an input character in editors such as EMACS, or backing up in a menu for some applications. The Hewlett Packard HP 2640 terminals had a key for "display functions" mode which would display graphics for all control characters, include Esc to aid in debugging applications.

It is commonly used when the computer and the peripheral have only a single channel in which to send information back and forth. If the device in question is "dumb" and can only do one thing with the information being sent to it (for instance, print it) then there is no need for an escape sequence. However most devices have more than one capability, and thus need some way to tell data from commands.

Contents

[edit] Modem control

For instance, the Hayes command set defines a single escape sequence, +++. When the modem encounters this in a stream of data, it switches from its normal mode of operation which simply sends any characters to the phone, to a command mode in which the following data is assumed to be a part of the command language. You can switch back to the online mode by sending the O command.

The Hayes command set is modal, switching from command mode to online mode. This is not appropriate in the case where the commands and data will switch back and forth rapidly. An example of a non-modal escape sequence control language is the VT100, which used a series of commands prefixed by the Control Sequence Introducer, escape-[[.

[edit] ASCII Video Data Terminals

There is a fine line between a set of control characters and an escape sequence that may not exist at all. The earlier VT52 terminal used simple commands like escape-A, which is sufficiently simple to be considered a control character command language. However the VT52 also supported parameters, which a simple control language likely would not.

The VT100 terminal implemented the more sophisticated ANSI standard for functions such as controlling cursor movement, character set, and display enhancements. The Hewlett Packard HP 2640 series had perhaps the most elaborate escape sequences for block and character modes, programming keys and their soft labels, graphics vectors, and even saving data to tape or disk files.

[edit] Use in DOS and Windows

The use of GUI operating systems, which directly write to display cards, have largely made the use of escape sequence abandoned although a utility, ANSI.SYS, can be used to enable the interpreting of ANSI terminal escape sequences in a DOS command window in DOS or Windows. But, the escape sequence can still be used to create interactive random-access character based screen interfaces with the character based library routines such as printf without resorting to a GUI program.

Escape sequences date back at least to the 1874 Baudot code.

[edit] See also

[edit] External links

In other languages