How can I clear the screen without the Crt unit?

In article <5u2rmn$...@majakka.uwasa.fi> of Thu, 28 Aug 1997 06:35:51 in
comp.lang.pascal.borland, Timo Salmi <t...@uwasa.fi{omit.No.Emailed.Advert

Quote
i{*word*224}ts}> wrote:
>In article <M8ibYOAdfDB0E...@merlyn.demon.co.uk>,
>Dr John Stockton  <j...@merlyn.demon.co.uk> wrote:
>:In article <5tq94r$...@majakka.uwasa.fi> of Mon, 25 Aug 1997 00:30:03 in
>:comp.lang.pascal.borland, Timo Salmi <t...@uwasa.fi{omit.No.Emailed.Advert
>:i{*word*224}ts}> wrote:
>:>117. *****
>:> Q: How can I clear the screen without the Crt unit?

>:>  procedure ClrScreen;

>:This is UNTESTED, but I have used something like it with a Move in

>Thanks John. Would you please test it and repost the whole code. I
>would be pleased to include your addition to the item.

This is now revised and tested in various screen modes.  I'm not
intending at present to do more with it, but I shall keep a latest-good
copy at
        http://www.merlyn.demon.co.uk/programs/test_cls.pas

With a Move, one can save the screen for later restoration.

unit TEST_CLS { John Stockton, j...@merlyn.demon.co.uk >= 1997/09/08 } ;
{ Note : Similar code, with Move instead of FillChar, can be used to
  save/restore a text screen.  Pre-Condition : do not use Crt unit. }
interface
procedure TestCls ;
implementation

{$IFNDEF VER70}
const Seg0040 = $40 ; SegB000 = $B000 ; SegB800 = $B800 ;
{$ENDIF}

procedure WaitABit ;
var J : longint ;
begin for J := 1 to 3000000 do {OK for 486/dx33} end {WaitABit} ;

function ThisMode : byte ;
{ instead of LastMode, which requires Crt }
begin ThisMode := Mem[Seg0040:$49] end {ThisMode} ;

function Monochrome : boolean ;
const Mono = {Crt.Mono} 7 ;
MonoSet = [Mono, $56, $57] { $56,$57 are mono on **MY** Tandon PC } ;
begin Monochrome := ThisMode in MonoSet end {Monochrome} ;

procedure TestCls ;
var PScreen : pointer ;
  ScrSize, ScrSeg : word ; Cols : word ; Rows : byte ;
begin
if Monochrome then ScrSeg := SegB000 else ScrSeg := SegB800 ;
  PScreen := Ptr(ScrSeg, 0) ;   (*** Add allowance for Page Number ***)
  Cols := MemW[Seg0040:$4A] ; Rows := Succ(Mem[Seg0040:$84]) ;
  ScrSize := 2 * Cols * Rows ;
  FillChar(PScreen^, ScrSize, 0) { Could use Move here } ;
  Writeln(^M'  ScrSeg=', ScrSeg, '':5, Cols, ' * ', Rows,
    ' *2= ', ScrSize, MemW[Seg0040:$4C]:7) ;
  WaitABit end {TestCls} ;

BEGIN ;
END.

If ANSI.SYS is installed, "Write(#27'[2J') ;" will do it
  (but *only* without Crt, unless 'CON' reassigned).  Consider
redirection!

For clear, but not copy, consider Int 10/06 with AL=0.

On Wed, 3 Sep 1997 22:10:48 in comp.lang.pascal.borland, michael b

Quote
  <micha...@frontiernet.net> wrote:  it works for me.

  procedure cls; assembler;
    asm  MOV AH,0Fh ; INT 10h ; MOV AH,0 ; INT 10h  end ;
  begin cls end.

"Critical Dates" - see sig - may interest some of you; also some of the
links on my pages!

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web URL: http://www.merlyn.demon.co.uk/ -- includes FAQqish topics and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  My list of Critical Dates is : http://www.merlyn.demon.co.uk/miscinfo.htm#CDs