We help IT Professionals succeed at work.

question for Slick

palare98
palare98 asked
on
Medium Priority
241 Views
Last Modified: 2010-04-06
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.
Comment
Watch Question

Commented:
was your solution in assembly ?

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.

Author

Commented:
I'm not sure how he wrote it.  But it works great.  I have not seen the source code for it.  It goes up under the sysutils, and you call it with cls.  Anyhow thank you for your help.  When I am ready to learn the right way to actually code it, I'm sure that your code will be invaluable.  Thanks.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.