JRS: In article <19990508154541.07989.00000...@ng-cl1.aol.com> of Sat,
8 May 1999 19:45:41 in news:comp.lang.pascal.borland, MajicPat
Quote
<majic...@aol.com> wrote:
>I am a beginner and am using Turbo Pascal 7.0 with DOS on a computer with a
>processor speed of 400 MHz. I simply would like to know how to clear the
>screen without using the CRT unit (and thus incurring the "divide by 0" error
>message). In his FAQs (ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip), Timo Salmi
>suggests three simple solutions. I have tried all three but cannot get any to
>work.
>I'll address his first suggestion for clearing the screen, and if someone can
>help me make it work, I won't worry about the other two.
>Below is a short program that I wrote to test the ClrScreen procedure suggested
>in Timo Salmi's FAQs (#117.) Calling this procedure does indeed clear the
>screen, but then I cannot write anything to the screen after that. According
>to Borland's Turbo Pascal "Language Guide" (p. 144), the CRT unit's ClrScr
>procedure should clear the screen and also return the cursor to the upper
>left-hand corner. Perhaps Salmi's substitution does not do everything that
>ClrScr does.
On my PII/300 PC in a DOS box, your program does what you want. What
system software are you using? Which DOS? Is it a Win98 machine
emulating DOS? Is it colour?
What happens if you write characters to the odd or even positions of the
screen area? One should be gaudy, the other legible.
If you don't mind the cursor ending up on the last line rather than the
first,
for J := 1 to NumberOfLines do Writeln ;
will clear the screen quickly enough for most purposes at 400 MHz (but
maybe not on the original IBM PC!).
A GoAtXY (TSFAQP#124) should put the cursor at the top, or a direct Int
$10 *should* work:
procedure GoXY(X, Y : byte) { Position Cursor } ; assembler ;
asm mov ah,$02 ; mov bh,0 ; mov dh,Y ; mov dl,X ;
{ Michael Kennedy says some old systems may need Push BP, Pop BP }
push BP ; int $10 ; pop BP end {GoXY} ;
BTW, I expect that your program IS writing to the screen, but in black-
on-black, as alluded to in TSFAQP.
In Timo's code, one should use not FillChar but FillWord, to fill the
screen with character-attribute pairs, where the character is #$20=space
and the attribute is what it needs to be. The snag is that FillWord is
not available as standard, though it may be easy to write (PS?).
Try Timo's, but filling with #$20 bytes - it should clear the screen to
green, and you may be able to write on it.
When you do find out what the real problem was, please post the
explanation here.
--
? John Stockton, Surrey, UK. j...@merlyn.demon.co.uk Turnpike v4.00 MIME. ?
Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
<A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.