Link to home
Start Free TrialLog in
Avatar of palare98
palare98

asked on

Clear Screen in Delphi's Console Application

I am in a class learning Pascal.  We are using the Console Application function of Delphi.  In Turbo Pascal there was a built in function for clearing the screen.  It was something like ClrScr.  Is there something like this in Delphi?  I'm not looking for some huge procedure to do this.  I already have one of those.
ASKER CERTIFIED SOLUTION
Avatar of edey
edey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hello palare98, there isn't much (that I could find) in delphi to do things whith Console apps except write and read. I had to use windows API console fuctions to do things like change the text and background colors. As for clearing the screen, I never did see if there was an API for clear Screen? ? I clear the screen just by using  WriteLn('');   enough times to get every thing off the screen. Here is the Code I use to do that - - -



program unins;
{$APPTYPE CONSOLE}
uses
  Windows,
  Messages,
  SysUtils;

var
Str1: String;
hStdOut: HWnd;
ScreenBufInfo: TConsoleScreenBufferInfo;
Coord1: TCoord;
i: Integer;

begin
hStdOut := GetStdHandle(STD_OUTPUT_HANDLE);
Writeln('This is a test?');
Writeln('Does it work?');
ReadLn(Str1);
WriteLn('1 Ok we got anoter test line here');
WriteLn('2 Ok we got anoter test line here');
WriteLn('3 Ok we got anoter test line here');
WriteLn('4 Ok we got anoter test line here');
WriteLn('5 Ok we got anoter test line here');
WriteLn('6 Ok we got anoter test line here');
WriteLn('7 Ok we got anoter line here');
WriteLn('8 Ok we got anoter line here');
WriteLn('9 Ok we got anoter line here');
ReadLn(Str1);



// code for Clear Screen
GetConsoleScreenBufferInfo(hStdOut, ScreenBufInfo);
{the GetConsoleScreenBufferInfo API gets the size of
the buffer I need}
for i := 1 to ScreenBufInfo.dwSize.Y do
WriteLn('');
Coord1.X := 0;
Coord1.Y := 0;
SetConsoleCursorPosition(hStdOut, Coord1);
{SetConsoleCursorPosition API sets your cursor
to the Coord1, at 0, 0    the beginging}


ReadLn(Str1);

end.

- - - - - - - - - - - - - - - - - - -
this works for me, but I don't use Console very much.
maybe you have not used any windows API yet. let me know
Avatar of palare98
palare98

ASKER

I will try it an let you know.  We have not gotten into API yet.
How'd you make out?

GL
Mike
I ended up getting what I needed from a dcu that was written by a guy that I know.  I am going to give each of you points though.

Slick, I will write another question for you as soon as I get the chance.
Thanks, Glad you were able to get a solution.

GL
Mike