11、Function KeyPressed : Boolean;
KeyPressed函数扫描键盘缓冲区,确认是否有键按下。如果有,则返回True,如
果没有,则返回False。Shift、Alt、Ctrl不包括在内。
例子:
Program Example2;
uses Crt;
{ Program to demonstrate the KeyPressed function. }
begin
WriteLn('Waiting until a key is pressed');
repeat
untilKeyPressed;
{ The key isnot Read,
so it shouldalso be outputted at the commandline}
end.
12、Procedure LowVideo;
低亮度显示文本。
13、Procedure NormVideo;
NormVideo以正常亮度显示文本,为默认值。
14、Procedure NoSound;
让扬声器停止发出声音。并不是所有操作系统都支持。
例子:
Program Example16;
uses Crt;
{ Program to demonstrate the Sound and NoSoundfunction. }
var
i : longint;
begin
WriteLn('Youwill hear some tones from your speaker');
while(i<15000) do
begin
inc(i,500);
Sound(i);
Delay(100);
end;
WriteLn('Quietnow!');
NoSound; {Stopnoise}
end.
15、Function ReadKey : Char;
ReadKey从键盘缓冲区读取一个键并返回。如果功能键被按下,则返回0(ASCII码),
如果执行该函数后并未有键按下,则程序将一直等到有键按下才继续执行下面的
代码。Linux下的键盘映射可能会导致错误并由ReadKey报告,因此需谨慎使用
ReadKey。
例子:
Program Example3;
uses Crt;
{ Program to demonstrate the ReadKey function. }
var
ch : char;
begin
writeln('PressLeft/Right, Esc=Quit');
repeat
ch:=ReadKey;
case ch of
#0 : begin
ch:=ReadKey; {Read ScanCode}
casech of
#75 : WriteLn('Left');
#77: WriteLn('Right');
end;
end;
#27 :WriteLn('ESC');
end;
until ch=#27{Esc}
end.
16、Procedure Sound (hz : word);
使扬声器发出hz赫兹的声音。在Windows下,系统播放声音的频率参数被忽略。
(意思好像是播放的声音的频率和参数有点差距)在在其他操作系统下,此过
程可能不会执行。
17、ProcedureTextBackground (CL: Byte);
TextBackground根据参数CL设置背景颜色(执行后输入输出文本的),CL为预定
的颜色常量之一。
例子:
Program Example13;
uses Crt;
{ Program to demonstrate the TextBackground function.}
begin
TextColor(White);
WriteLn('Thisis written in with the default background color');
TextBackground(Green);
WriteLn('Thisis written in with a Green background');
TextBackground(Brown);
WriteLn('Thisis written in with a Brown background');
TextBackground(Black);
WriteLn('Backwith a black background');
end.
18、Procedure TextColor (CL: Byte);
TextColor根据CL设置前景色(执行后输入输出文本的颜色),CL为预定的颜色
常量之一。
例子:
Program Example12;
uses Crt;
{ Program to demonstrate the TextColor function. }
begin
WriteLn('Thisis written in the default color');
TextColor(Red);
WriteLn('Thisis written in Red');
TextColor(White);
WriteLn('Thisis written in White');
TextColor(LightBlue);
WriteLn('Thisis written in Light Blue');
end.
19、procedure TextMode(Mode: Integer);
TextMode设置屏幕文本模式(即屏幕的行和列数),较低的字节是用于设置VGA文本
模式。这个过程只在DOS下执行。
20、Function WhereX : Byte;
WhereX返回当前光标的横坐标(相对于当前窗口)。
例子:
Program Example7;
uses Crt;
{ Program to demonstrate the WhereX and WhereYfunctions. }
begin
Writeln('Cursor postion: X=',WhereX,' Y=',WhereY);
end.
21、Function WhereY : Byte;
WhereY返回当前光标的纵坐标(相对于当前窗口)。
例子:
Program Example7;
uses Crt;
{ Program to demonstrate the WhereX and WhereYfunctions. }
begin
Writeln('Cursor postion: X=',WhereX,' Y=',WhereY);
end.
22、Procedure Window (X1, Y1, X2, Y2:Byte);
Window在屏幕上创建一个窗口(即一块区域),X1、Y1为窗口的起始坐标,X2、
Y2为窗口的结束坐标。执行后光标自动转到X1、Y1处。
例子:
Program Example5;
uses Crt;
{ Program to demonstrate the Window function. }
begin
ClrScr;
WriteLn('Creating a window from 30,10 to 50,20');
Window(30,10,50,20);
WriteLn('Weare now writing in this small window we just created, we '+
'can''t get outside it when writing long lines like this one');
Write('Pressany key to clear the window');
ReadKey;
ClrScr;
Write('Thewindow is cleared, press any key to restore to fullscreen');
ReadKey;
{Full Screen is 80x25}
Window(1,1,80,25);
Clrscr;
Writeln('Backin Full Screen');
end.