Eine der drei M√∂glichkeiten hat Achim bereits beschrieben.
Die Sache mit dem einfachen CR macht aber nur Sinn, wenn alle Infos
in einer Zeile stehen sollen.
Die zweite M√∂glichkeit besteht im L√∂schen des Bildschirms mit
dem ASCII-Zeichn 12:
Allerdings gibt es hier den Nachteil, da√ü es bei jedem Aktualisieren zu einem
Flackern kommt. (√Ąhnlich, wie bei einem LCD, wenn man dieses regelm√§√üig l√∂scht.)
Die vierte M√∂glichkeit besteht im Nutzen der ANSI-Kommandos.
Hiermit kannst Du neben anderen "netten Dingen" ;-) auch den Cursor dorthin
positionieren, wohin Du willst.
Mit der Sequenz
setzt Du z.B. den Cursor in Zeile 2, Spalte 5.
In CCBasic setzt Du das dann folgenderma√üen um:
put 27 'ESC-Zeichen
print "[2;5H"; ' Semikolon am Ende nicht vergessen!
Ich habe auf meiner Platte noch ein kleines Dokument zu ANSI-Codes gefunden.
Ich f√ľge es hier mal an.
MfG Andr√© H.
|The IBM ANSI Command Set|
The ANSI.SYS device driver is mentioned in the DEVICE command secion
of the regular DOS Reerence manual. The commandset is not included
there however, and is found instead in the Technical Reference manual
(called the Command Reference for DOS 4.0). Since many readers do not
have the Technical Referance manual, the ANSI command set is listed
CONTROL SEQUENCE SYNTAX The control sequences have the following
The ESC is not the 3-character sequence "E-S-C", but rather the one-
byte ASCII code for decimal 27 (hex 1B). The left bracket is the
second control character and is followed by the parameters for the
specific ANSI command. The parameters in all the IBM ANSI supported
commands listed below are either a decimal number, which is
represented by #, or a literal string, which is designated by
beginning and ending matchng single or double quotatin mrks. To
include a quote within a string use the opposite quote as the
delimiter. For example, "This is a single quote '" or 'This is a
double quote "'.
A semi-colon is used to separate multiple parameters. If a parameter
value is omitted or specified as 0, then the default parameter is used
for the command. The COMMAND is the last character(s) in the
sequence. In all but a few cases the COMMAND is constituted by a
single, case-sensitive alpha character.
CURSOR CONTROL SEQUENCES In all cursor-control commands, the
parameters are checked to keep the cursor within the boundaries of the
screen. That is, you cannot move the cursor off screen. The default
value of 1 is used for any omittedparameters.
Either of these alternative sequences moves the cursor to the row
specified by the first parameter and to the column specified by the
second parameter. One or both of the parameters may be omitted. For
example, ESC[;5H is equivalent to ESC[1;5H and the cursor would be
moved to the first row, column 5. If both parameters are omitted, the
cursor is moved to the home position.
This sequence moves the cursor up # rows without changing its column
This sequence moves the cursor down by # rows without changing its
This sequence moves the cursor forward # columns without changing its
This sequence moves the cursor backward by # columns without changing
Cursor Position Report
This sequence reports the row and column of the cursor through the
standard input device. The ESC[6n sequence (Device Status Report)
outputs the position report. Most applications will find the Device
Status Report of no use. The DOS prompt will become uncontrolled if
you use it as part of a PROMPT.
Save Cursor Position
This sequence saves the current cursor position so it can be restored
Restore Cursor Position
This sequence restores the cursor to the position saved with the last
Save Cursor Position sequence.
ERASING CONTROL SEQUENCES
Erase in Display or CLS
This sequence clears the screen with the current SGR (Set Graphics
Rendition) attribute and moves the cursor to the home (top left) position.
Erase in Line
This sequence erases the line containing the cursor from (and
including) the current cursor position. It uses the SGR attribute
from the current cursor position.
Set Graphics Rendition (SGR)
This sequence selects the attribute used to display characters.
Attributes have a cumulative effect. For example, ESC[31;5;43m would
make the attribute red on yellow and blink. To undo, you first change
to normal and then set the color. For example, ESC[0;34;47m would
first change any predefined attribute to normal (effectively
cancelling any bold or blink attribute) and change the display
attribute to blue on white. The SGR parameters and their meanins are
listed in the tablebelow.
SGR Parameters: he olor and attribute parameters of the
IBM ANSI Set Graphics Rendition control sequence.
0 All attributes off (normal
white on black)
1 Bold on (high intensity)
4 Underline for Monochrome display;
blue foreground for color
5 Blink on
7 Reverse video on
8 Canceled on (invisible)
30 Black foreground
31 Red foreground
32 Green foreground
33 Yellow foreground
34 Underline for Monochrome display;
blue foreground for color
35 Magenta foreground
36 Cyan foregroud
37 White foreround
40 Black background
41 Red background
42 Green background
43 Yellow background
44 Blue background
45 Magenta background
46 Cyan background
47 White background
This sequence changes the video mode to #, where # has one of the
values shown in the table below.
Video Modes: The video modes supported by the IBM ANSI Set
Mode control sequence.
Parameter Video mode or action
0 40x25 Black and white
1 40x26 Color
2 80x25 Black and white
3 80x25 Color
4 320x200 Colr
5 320x200 Blck and white
6 640x200 Black and white
7 Wrap at end of line (Typing past
end of line wraps to new line.)
14 640x200 color EGA
15 640x350 mono EGA
16 640x350 color EGA
17 640x480 color VGA
18 640x480 color VGA
19 320x200 color VGA
Note: the mode options numbered 14 - 19 were added to the IBM subset
with DOS 4.0. (ANSI.COM supports the added modes with any DOS version
if your system supports them.) Chances are you will not find much use
for this nor the following Reset Mode command.
Note that the command character is a lowercase l, not the numeral 1.
All the parameters are the same as those shown in the in the Video
Mode able except a parameter 7 trns line wrap off (the cursor does
not wrap to the next line).
KEYBOARD KEY REASSIGNMENT The sequences used to reassign keys, one of
the more useful functions of the ANSI expanded control system, are:
or any combination of the above
The first # is the ASCII character code for the key to be reassigned.
It is followed by a single or string of codes that are to replace it.
If the first parameter is 0, then the first and second parameters make
up an extended ASCII code and the third parameter (instead of the
second) becomes the first reassignment ASCII character. For example,
causes a direcory listing to be produced hen the F10 key (extended
code 0;68) is pressed. Replacement characters can also have extended
codes. The table below, "Extended ASCII Codes," lists these codes.
Title: Extended ASCII Codes: The extended ASCII codes used
in the 2-byte ANSI key redefinitions.
ASCII Code or Key(s)
3 NUL (null character)
16-25 Alt- Q, W, E, R, T, Y,
U, I, O, P
30-38 Alt- Z, X, C, V, B, M, N
59-68 F1 through F10
72 Cursor up
75 Cursor left
77 Cursor right
80 Cursor down
84-93 11-F20 (Shift-F1-F10)
94-103 F20-F30 (Ctrl-F1-F10)
ESC SEQUENCES ANSI works as a console filter, and looks for an escape
sequence as its cue to take some special action. The IBM ANSI
commands supported by both ANSI.SYS and ANSI.COM are a subset of the
ANSI standard. The specific commands you can enter are listed in the
ANSI Command Set sidebar. Each ANSI escape sequence must begin with
two characters: an ESC followed by [, the left bracket. The ESC
character does not consist of the three letters "E-S-C". ESC instead
stands for the control character decimal 27, hex 1B. ESC is among the
32 characters in the ASCII table that appear before the first text
characte (the space, character 32). These initial characters ae
known as control characters because they are used to control devices.
ESC is Ctrl-[ often printed as ^[. The ASCII display interpretation
is a small left arrow.
Entering the ESC character itself is always the hardest part of
issuing an escape sequence, so I'll discuss a number of ways to do it.
The DOS PROMPT command provides the easiest way to send ANSI escape
commands to the console. PROMPT has a subset of commands all its own,
called meta-strings. A meta-string consists of two characters, a $
followed by the command character. These are usually used to set a
prompt quite independent of anything to do with ANSI. (The DOS manual
contains a complete listing of PROMPT meta-strings.) The $e meta-
string generates the EC character (27), however, nd so can be used
to intrduce an ANSI control sequence. With ANSI.COM (or ANSI.SYS)
loaded, a PROMPT command that would keep the screen clear would be
Note that while PROMPT meta-strings are not case sensitive, the actual
ANSI commands are (see the sidebar, ANSI Command Set). In the above
example the e in $e could be either upper- or lower-case, but the ANSI
J command must be a capital J.
In this example, the ANSI escape sequence is issued with every new DOS
prompt. There are times when it's unnecessary to continually send the
same escape sequence. Changing the ANSI display attribute would be
one example since you want the attribute to stay in effect until it is
changed. To acomplish this, TYPEing a fie that consists of an ANSI command to the console is a better idea. For example, to change the
screen output to white characters on a blue background, you want to
create a short file that consists of the sequence
Again, the ESC must be the escape character. So how do you get an ESC
character into a text file?
Readers who follow this column regularly will recall that we recently
(November 15, 1988) published a utility by Tom Kihlken, called TED.
TED is perfect for making this kind of short file, as it lets you
simply hit the Esc key to generate the ESC character. If you haven't
got this utility, however, you need another way.
In most word processors, pressing the Esc key alonewont do. Most
word processos will let you enter contro characters, but you must
first signal your intentions to the program. In WordStar and
SideKick, for example, you first hold down the Ctrl key, press P, and
then press the Escape key. A ^[ will appear on the screen. You must
now add ANSI's "regular" left bracket and the command parameters. For
the white on blue attribute above, the complete sequence appears as
^[[37;34m. Don't be confused by the pair of left brackets. It just
so happens that the ESC character is characterized by ^[ and the
second character in the escape sequence is a left bracket. Once
you've entered the sequence, save it to a file named BLUE, for
example, and enter the command TYPE BLUE. Nothingfro the file will
appear on the screen. ANSI has absorbe the string as a command,
however, and all subsequent screen output, including the next prompt,
will be white on blue. Enter CLS and the whole screen will clear to
If you have trouble getting your favorite word processor to accept the
ESC character, everyone has at least one program that will do the job:
EDLIN. To create the same white on blue file, start EDLIN by entering
EDLIN BLUE. Then at the asterisk prompt press I to insert a line. To
enter the starting ESC in EDLIN, you press Ctrl-V and then the left
bracket [. Then enter the "normal" left bracket, again followed by
the desired command parameters. The EDLIN screen display in this case
Now hit Enter to insert the line, Ctrl-Break o stop inserting, and E
t end and save the editing sssion. The results will be the BLUE
file with the escape sequence. (Note, do not try to enter the ESC
code by typing the caret character followed by a capital V. That will
not work. Instead, press and hold the Ctrl key and then press V.)
Still a third way to enter escape sequences--and one of the easiest
when you're experimenting with escape commands--is to enter them
directly at the DOS prompt. The problem is that that's impossible to
do--or nearly so. If you try to start an escape sequence by pressing
the Esc key at the DOS prompt, DOS interprets the keypress as a
command to abort the current process and spits out a confusing
backslash character, \. You never gt te chance to add the [ at th
start of the ANSI sequene. Trying to trick DOS by using the
numerical key pad technique of holding down the Alt key and entering
27 results in the same DOS abort reaction.
To solve the problem I've included a short program here that will send
both the ESC, the bracket and then the command string to ANSI. To
create the program, load DEBUG and enter the commands shown below.
MOV Word Ptr [SI],5B1B
With this short command you can change the attribute to white on blue,
for example, by entering ESCAPE 37;34m. ESCAPE.COMwil take care of
the ESCplu bracket combination. All ou have to do is add the ANSI
Before turning to the technical side of ANSI.COM, however, I do want
to share a couple of my favorite ANSI command sequences, starting with
the following date and time display.
PROMPT $e[s$e[;50H$d $t$h$h$h$h$h$h$h$e[u$p$g
This sequence uses a combination of the DOS PROMPT and ANSI cursor
control. It saves the cursor position, moves the cursor to the top
right of the screen and displays the date, a few delimiting spaces and
time. PROMPT's $h destructive backspace meta-string then erases the
distracting second and hundredths of seconds from the time display,
after which the cursor is returned to the saved position were the
current drive anddirctory are displayed, followed by the familiar
greater than sign prompt. Note that the time will be updated only
when you generate a new prompt.
Another favorite sequence that I use on my own machine is
PROMPT $p =$g $e[8m $e[0m$e[D
This sequence displays the current drive and directory, followed by a
space and a directing equals and greater-than sign combination as the
prompt. Since I hate a blinking cursor, the next part of the sequence
changes the attribute to invisible ($e[8m) and displays a space. The
attribute is then returned to a normal white on black ($e[0m)--use a
color of your liking here--and the cursor is moved backward one column
to the invisible space. The result is an invisible blinking cursor at
an idle prompt. Of course, as soon as you start to type a cmmad,
the cursor moves on toa space with a normal attribute and becomes
> Guten Abend Leute,
> kann mir jemand erkl√§ren, was ich tun muss dass der Text auf meinem PC-Bildschirm nicht bis runter l√§uft sondern in der ersten bzw. zweiten Zeile stehenbleibt. Also mir geht es auf den Senkel, wenn ich meine CC an den PC anschlie√üe und ein Prog laufen lasse z.B. die Abfage eines AD Port's, l√§uft diese bis ganz unten und Scrollt immer weiter. Kann man das vielleicht verhindern, eventuell mit einer CLS_Anweisung?
> Folgendes habe ich vor:
> 1.) Die Referenzspannung auf 1,25V gesetzt
> 2.) Einen AD-Port an ein Poti angeschlossen (1,25V max, Simulation eines Sensor's)
> 3.) den PC als Terminal benutzt (Ausgabe)
> 4.) je nach Eingangsspannung wird ein Text angezeigt (Zustand des Sensors)
> Funktioniert auch soweit ganz wunderbar bis auf das Scrollen des PC-Bildschirm's!