Escape Character

Print Topic  Return to Overview  Previous Topic  Next Topic 

TCC recognizes a user-definable escape character. This character gives the character that follows a special meaning; it has a different purpose than the ASCII ESC that is often used in ANSI X3.64 and printer control sequences.

 

The default escape character is a caret (^, ASCII: 94). If you don't like the default escape character, you can pick another character using the SETDOS /E command, or the Escape character configuration option. If you plan to share aliases or batch files on other TCC configurations, use the %= pseudovariable, which is accepted in all of them, regardless of the actual value assigned to the escape character. See the section on Special Character Compatibility for details about choosing compatible escape characters. Note that if you change the default, your batch files will not work under CMD.EXE and you won't be able to run third-party batch files.

 

Ten special characters are recognized when they are preceded by the escape character. The combination of the escape character and one of these characters is translated to a single character, as shown below. The special characters which can follow the escape character are:

 

Codes for Escape Characters

 

bbackspace
ccomma ,
ethe ASCII ESC character (code 27)
fform feed
kback quote `
nline feed
qdouble quote "
rcarriage return
sspace
thorizontal tab character

 

If you follow the escape character with any other character, the escape character is removed and the second character is copied directly into the command line. This allows you to suppress the normal meaning of special characters (such as ? * / \ | " ` > < and &). For example, to display a message containing a > symbol, which normally indicates redirection:

 

echo 2 is ^> 4

 

The escape character has an additional use when it is the last character on any line of  a batch file. TCC recognizes this use of the escape character to signal line continuation:  it removes the escape character and appends the next line to the current line before executing it.

 

WARNING: Escape characters are considered to be normal characters on the right side of a pipe.

 

Note: The term escape character has two additional usages not related to the above description, as detailed in the description of the PROMPT command and in ASCII, Key Codes and Key Names.

Topic "escape.htm" last edited 5/13/2008. ©2008  JP Software, Inc.
Keywords: EscapeChar,Escape character,Special Character Compatibility,^ caret,Ctrl-X