home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
GRAPHICS
/
ANSIHOW.ZIP
/
ANSIHOW.BAT
next >
Wrap
DOS Batch File
|
1990-03-06
|
4KB
|
72 lines
ECHO OFF
ECHO This bat file shows how to use ANSI control codes within bat files to get
ECHO lots of
c
o
l
o
r
and
special effects
.
ECHO View this file in an ASCII-only editor to see the ansi sequences.
ECHO An ANSI control code can do lots of things. Each ANSI code has the same
ECHO basic format. First is the escape command. We will show it as ESC in this
ECHO demonstration. In an ASCII editor, it will appear ^[, and may be entered in
ECHO the batch file by ALT-027. Next is the "[" character. Then the parameters.
ECHO Be sure to pay attention to upper and lower case letters in the parameters.
ECHO ---------------------------------------------------------------------
ECHO To clear the screen and home the cursor: ESC[2J
ECHO To locate the cursor to row #, column, *: ESC[#;*H
ECHO To move the cursor up # rows: ESC[#A
ECHO To move the cursor down # rows: ESC[#B
ECHO To move the cursor right # columns: ESC[#C
ECHO To move the cursor left # columns: ESC[#D
ECHO To store the current cursor position: ESC[s
ECHO To return to the stored cursor position: ESC[u
ECHO -----------------------------------------------------------------------
ECHO To set a color and attribute: ESC[#;...;#m
ECHO where #;...;# is a list of attributes
ECHO -----------------------------------------------------------------------
ECHO The next page contains a list of attribute values
PAUSE
ECHO Replace # IN ESC[#;...;#m with the value for the desired
ECHO attribute, separating multiple parameters with a semi-colon.
ECHO -----------------------------------------------------------------------
ECHO Value Attribute
ECHO 0 All attributes off (normal white-on-black)
ECHO 1
Bold on (high intensity)
ECHO 4
Underscore on (monochrome display only)
ECHO 5
Blink on
ECHO 7 Reverse video on
ECHO 8 Cancelled on (invisible, not demonstrated)
ECHO -----------------------------------------------------------------------
ECHO Foreground Background
ECHO Value Value Color
ECHO 30 40
Black
ECHO 31 41
Red
ECHO 32 42
Green
ECHO 33 43
Yellow
ECHO 34 44
Blue
ECHO 35 45
Magenta
ECHO 36 46
Cyan
ECHO 37 47
White
ECHO -----------------------------------------------------------------------
ECHO Example: This is
Green on Red,
Blue on White,
Blinking Bright Yellow on Blue
.
ECHO 1H
PAUSE
ECHO You can also set the screen size with ANSI codes. The ESC[=#h sequence sets
ECHO screen modes according to the following table:
ECHO H # value Mode
ECHO 0 40x25 black & white
ECHO 1 40x25 color
ECHO 2 80x25 black & white
ECHO 3 80x25 color
ECHO 4 320x200 color
ECHO 5 320x200 black & white
ECHO 6 640x200 black & white
ECHO 7 Line Wrap On (typeing beyond end of line starts new line)
ECHO 1H
PAUSE
ECHO H=1h
This lets you do lots of
ECHO
interesting things with
ECHO
your batch files!
ECHO 1H
PAUSE
ECHO =3hHANSI codes can be used by adding them to the text you send to the
ECHO Hdisplay with the
ECHO
command.
ECHO 1HFor example, a blinking yellow on blue
HELLO
can be obtained with the line:
ECHO 10H"ECHO ^[[33;44;1;5mHELLO^[[0m"
ECHO 5HWhere " ^[ " is the ESC code (Use ALT-027 in an ASCII editor)