TURBO PASCAL

Новости

Программы   

Turbo Pascal 

Игры

Документация   

Странности

FAQ

Ссылки

Форум

Гостевая книга

Рассылка

Благодарности

Об авторе

26: How to get ansi control codes working in Turbo Pascal writes?

 A: It is very simple, but 
one has to be aware of the pitfalls.
Let's start from the assumption that ansi.sys or a corresponding
driver has been loaded, and that you know ansi codes. If you 
don't,
you'll find that information in the standard MS-DOS manual. To 
apply
ansi codes you just include the ansi codes in your write 
statements.
For example the following first clears the screen and then puts the
text at location 10,10:
   write (#27, '[2J');         (* the ascii code for ESC is 27 *)
   write (#27, '[10;10HUsing ansi codes can be fun');
If you want to test (as you should) whether ansi.sys or some some
replacement driver has been loaded, you can use the ISANSIFN
function from my ftp://garbo.uwasa.fi/pc/ts/tspa3470.zip.
Now the catches. If you have a
   uses Crt;
statement in your program, direct screen writes will be used, and
the ansi codes won't work. You have either to leave out the Crt
unit, or include
   assign (output, '');
   rewrite (output);
   :
   close (output);
Occasionally I have seen it suggested that one should just set
   DirectVideo := false;
This is a popular misconception. It won't produce the desired
result. I'm not claiming to know the reason for this quirk of Turbo
Pascal. Rather it is an observation I've made.
-From: Bengt Oehman 
d92bo@efd.lth.se with a later dicussion with Bob
Peck bpeck@prairienet.org and help from Duncan Murdoch
dmurdoch@mast.queensu.ca. The `DirectVideo:=False' 
statement only
tells the Crt unit to use BIOS calls instead of using direct
video-memory writes. A demo program to illustrate the screen 
writing
modes follows:
Program 
ScreenWriteDemo;
USES Crt;
BEGIN
  Writeln('This is written directly to the video memory');
  DirectVideo:=False;
  Writeln('This is written via BIOS interrupt calls (int 10h)');
  Assign(Output,'');
  Append(Output);
  Writeln('This is written via DOS calls (int 21h)');
END.
A note: The latter could 
be also written as
  Writeln(Output, 'This is written via DOS calls (int 21h)');
since the writeln default is the standard output.

 Contents

На первую страницу

Rambler's Top100 Rambler's Top100
PROext: Top 1000

(с)Все права защищены

По всем интересующим вопросам прошу писать на электронный адрес

Hosted by uCoz