Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Re: Scrollen des PC-Bildschirms Kategorie: C-Control I V1.1 (von André H. - 3.05.2007 10:57)
 Als Antwort auf Scrollen des PC-Bildschirms von Klaus - 2.05.2007 23:41
André H. nutzt:  CC1-Unit V1.1, Open-Micro, Open-Mini, Open-Mini M-Unit, Open-Mini Station, C-Control 2
Hallo Klaus,

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:
put 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
ESC[2;5H
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.

Ansicmd.txt
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
here.

CONTROL SEQUENCE SYNTAX  The control sequences have the following
general form:

ESC[parametersCOMMAND

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.

Cursor Positon

ESC[#;#H    

   or
ESC[#;#f

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.

Cursor Up

ESC[#A

This sequence moves the cursor up # rows without changing its column
position.

Cursor Down

ESC[#B

This sequence moves the cursor down by # rows without changing its
column position.

Cursor Forward

ESC[#C

This sequence moves the cursor forward # columns without changing its
row.

Cursor Backward

ESC[#D

This sequence moves the cursor backward by # columns without changing
its row.

Cursor Position Report

ESC[#;#R

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

ESC[s

This sequence saves the current cursor position so it can be restored
later.

Restore Cursor Position

ESC[u

This sequence restores the cursor to the position saved with the last
Save Cursor Position sequence.


ERASING CONTROL SEQUENCES  

Erase in Display or CLS

ESC[2J

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

SC[K

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)

ESC[#;...;#m

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.

Parameter     Attribute
---------     ---------    
     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

Set Mode

ESC[=#h

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.

Reset Mode

ESC[=#l

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:

ESC[#;#;...#p
or ESC["string"p
or ESC['string'p
or ESC[#;"string";#;#;"string";#p
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,

ESC[0;68;"Dir";13p

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.

Extended      Meaning
ASCII Code    or Key(s)
----------    ---------
    3         NUL (null character)
   15         Shift-tab
  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
   71         Home
   72         Cursor up
   73         PgUp
   75         Cursor left
   77         Cursor right
   79         End
   80         Cursor down
   81         PgDn
  82         Insert
   83        Delete
  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

PROMPT $e[2J

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

ESC[37;34m

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
blue.

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
will be

1:* ^V[[37;34m

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.

A    
MOV    SI,0080    
MOV    CL,[SI]    
XOR    CH,CH    
INC    CX    
MOV    Word Ptr [SI],5B1B    
LODSB    
INT    29    
LOOP   010C    
RET

N ESCAPE.COM    
RCX    
12    
W    
Q

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
command parameters.

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
visible again.




> 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!
>
> Gruß
> Klaus

 Antwort schreiben

Bisherige Antworten:

Re: Scrollen des PC-Bildschirms - Nachtrag (von André H. - 3.05.2007 11:11)