[comp.lang.pascal] Ansi Color

fer9483@tesla.njit.edu (04/19/91)

How di I print ANSI control codes from turbo pascal 5.5?

like the code for a read foreground is:

ESC [31m

how do i print ut using writeln?

                               Frank Rachel

sjs@gnv.ifas.ufl.edu (04/20/91)

In article <1991Apr19.122136.1@tesla.njit.edu>, fer9483@tesla.njit.edu writes:
> How di I print ANSI control codes from turbo pascal 5.5?
> like the code for a read foreground is:
> ESC [31m
> how do i print ut using writeln?
>                                Frank Rachel

write (chr(27),'[31m');

vu@spot.Colorado.EDU (Vu~ Tua^'n Ha?i) (04/20/91)

In article <1991Apr19.165852.116@gnv.ifas.ufl.edu> sjs@gnv.ifas.ufl.edu writes:
>In article <1991Apr19.122136.1@tesla.njit.edu>, fer9483@tesla.njit.edu writes:
>> How di I print ANSI control codes from turbo pascal 5.5?
>> like the code for a read foreground is:
>> ESC [31m
>> how do i print ut using writeln?
>>                                Frank Rachel
>
>write (chr(27),'[31m');

	I would like to add: do not use the crt unit since crt.write
	seems to write directly to the video buffer, which make the
	statement above doesn't work.

	Hai Vu
-- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hai Vu     vu@spot.colorado.edu     University of Colorado at Boulder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ts@uwasa.fi (Timo Salmi) (04/20/91)

In article <1991Apr19.122136.1@tesla.njit.edu> fer9483@tesla.njit.edu writes:
>How di I print ANSI control codes from turbo pascal 5.5?
>like the code for a read foreground is:
>ESC [31m
>how do i print ut using writeln?

26. *****
 Q: 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 MsDos 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');
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.

...................................................................
Prof. Timo Salmi
Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

bobb@vice.ICO.TEK.COM (Bob Beauchaine) (04/21/91)

In article <1991Apr20.143655.13621@uwasa.fi> ts@uwasa.fi (Timo Salmi) writes:
> Q: How to get ansi control codes working in Turbo Pascal writes?
>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.
>

  Being one of the perpetrators of this hoax, I would like to know
  why this solution doesn't work.  I checked the manual; it says
  that setting the DirectVideo variable false coerces Turbo into
  using Bios for all write/writeln statements.  I assume the Ansi
  driver intercepts the video interrupt for output.  What gives?
  Is Ansi.sys not intercepting the correct vector, or does Turbo
  use a "non standard" output method?

  BTW, the results are the same using Ansi.com, PC Magazine's 
  enhanced ansi driver.

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 

Bob Beauchaine bobb@vice.ICO.TEK.COM 

C: The language that combines the power of assembly language with the 
   flexibility of assembly language.

thoger@solan.unit.no (Terje Th|gersen) (04/21/91)

In article <7328@vice.ICO.TEK.COM> bobb@vice.ICO.TEK.COM (Bob Beauchaine) writes:


   In article <1991Apr20.143655.13621@uwasa.fi> ts@uwasa.fi (Timo Salmi) writes:
   > Q: How to get ansi control codes working in Turbo Pascal writes?
   >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.
   >

     Being one of the perpetrators of this hoax, I would like to know
     why this solution doesn't work.  I checked the manual; it says
     that setting the DirectVideo variable false coerces Turbo into
     using Bios for all write/writeln statements.  I assume the Ansi
     driver intercepts the video interrupt for output.  What gives?
     Is Ansi.sys not intercepting the correct vector, or does Turbo
     use a "non standard" output method?

     BTW, the results are the same using Ansi.com, PC Magazine's 
     enhanced ansi driver.

TP uses one of three different Writeln's, depending on the settings of
DirectVideo and whether Crt is USED. 

CRT + DirectVideo = TRUE  :  Directly to screen memory.
CRT + DirectVideo = FALSE :  Int 21h, Fn 40h, "Write File" with con as
			     the "file"
No CRT			  :  Int 21h, fn 09h, "Display String", the
			     most basic "write" of them all..

Regards,
  -Terje



--
____________________________________________________________________________
thoger@solan.unit.no       |                 Institute of Physical Chemistry
THOGER AT NORUNIT.BITNET   | Div. of Computer Assisted Instrumental Analysis
                           |               Norwegian Institute of Technology

Kai_Henningsen@ms.maus.de (Kai Henningsen) (04/25/91)

Terje Th|gersen thoger%solan.unit.no @ SUB schrieb am 21.04.1991, 14:15

TT>TP uses one of three different Writeln's, depending on the settings of
TT>DirectVideo and whether Crt is USED.
TT>
TT>CRT + DirectVideo = TRUE  :  Directly to screen memory.

True.

TT>CRT + DirectVideo = FALSE :  Int 21h, Fn 40h, "Write File" with con as
TT>                             the "file"

Wrong. It's INT 10h AH=09h, BIOS Video Write char/attr at cursor (plus AH=03h
get cursor, AH=02h Set cursor).

TT>No CRT                    :  Int 21h, fn 09h, "Display String", the
TT>                             most basic "write" of them all..

Wrong again. It is INT 21h AH=40h, DOS Write File.

MfG Kai