Special Character Compatibility |
|
If you want to share aliases, user defined functions, and batch files with other users, you need to be aware of possible differences in three important characters: the Command Separator (see Multiple Commands), the Escape Character (see Escape Character), and the Parameter Character (see Batch File Parameters).
The default values of each of these characters is shown in the following chart.
Product |
Separator |
Escape |
Parameter |
4DOS (obsolete) |
^ |
Ctrl-X |
& |
TCC (and CMD) |
& |
^ |
$ |
pseudovariable |
%+ |
%= |
|
In your batch files and aliases, and even at the command line, you can smooth over these differences in three ways:
| 1. | Use internal pseudovariables that contain the current special character, rather than using the character itself (see %+ and %=). For example, this command: |
if "%1" == "" (echo Parameter missing! & quit)
will only work if the command separator is an ampersand. However, this version works regardless of the current command separator:
if "%1" == "" (echo Parameter missing! %+ quit)
| 2. | Select a consistent set of characters from the Advanced tab of the configuration dialogs. |
| 3. | In a batch file, use the SETLOCAL command to save the command separator, escape character, and parameter character when the batch file starts. Then use SETDOS as described below to select the characters you want to use within the batch file. Use an ENDLOCAL command at the end of the batch file to restore the previous settings. |
You can also use the SETDOS command to change special characters on the command line.