主题:告诉大家Crt单元怎么用
小勇士来了2
[专家分:850] 发布于 2012-01-29 18:52:00
Crt单元对编pascal游戏起着不可缺少的作用, 下面我来讲解讲解(多顶顶!)
1、Procedure AssignCrt (Var F: Text);
AssignCrt指定一个文件F到屏幕。写入文件F一切转到屏幕代替。如果屏幕包含
一个窗口,全部写在窗口代替。注:功能接近于Writeln。
例子:
Program Example1;
uses Crt;
var
F : Text;
begin
AssignCrt(F);
Rewrite(F);
WriteLn(F,'This is written to the Assigned File');
Close(F);
end.
[fly]我QQ:1078350005, 大家一起顶啊![/fly]
回复列表 (共15个回复)
沙发
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:04:00
2、Procedure CursorBig;
使光标(不是鼠标图形)成为大矩形,在LINUX上不可用。
如果不明白的话,运行下面这个程序:
Program df;
Begin
Readln;
End.
仔细观察效果后,在运行下面这个程序:
Program df;
Uses crt;
Begin
CursorBig;
Readln;
End.
仔细对比后你就会知道什么意思了。
例子:
Program Example9;
uses Crt;
{ Program to demonstrate the ClrEol function. }
var I,J : integer;
begin
For I:=1 to 15 do
For J:=1 to 80 do
begin
gotoxy(j,i);
Write(j mod 10);
end;
Window(5,5,75,12);
Write('This line will be cleared from',
' here till the right of the window');
GotoXY(27,WhereY);
ReadKey;
ClrEol;
WriteLn;
end.
板凳
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:05:00
3、Procedure ClrScr;
ClrScr清除当前窗口(使用当前的颜色),并设置在当前窗口左上角的光标。(就是清屏)
例子:
Program Example8;
uses Crt;
{ Program to demonstrate the ClrScr function. }
begin
Writeln('Press any key to clear the screen');
ReadKey;
ClrScr;
Writeln('Have fun with the cleared screen');
end.
3 楼
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:05:00
4、Procedure CursorOff;
隐藏光标。在LINUX上无效。
5、Procedure CursorOn;
显示光标。在LINUX上无效。
4 楼
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:05:00
6、Procedure Delay (DTime: Word);
延迟等待指定的毫秒数。指定的秒数是个近似值(即可能有偏差),如果系统负载高,可能被关闭。
例子:
Program Example15;
uses Crt;
{ Program to demonstrate the Delay function. }
var
i : longint;
begin
WriteLn('Counting Down');
for i:=10 downto 1 do
begin
WriteLn(i);
Delay(1000); {Wait one second}
end;
WriteLn('BOOM!!!');
end.
5 楼
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:06:00
7、Procedure DelLine;
DelLine删除当前行。当前行一下的自动向上移动一行,并且在当前窗口底部插
入一空行,光标不移动。
例子:Program Example10;
uses Crt;
{ Program to demonstrate the InsLine function. }
begin
ClrScr;
WriteLn;
WriteLn('Line 1');
WriteLn('Line 2');
WriteLn('Line 2');
WriteLn('Line 3');
WriteLn;
WriteLn('Oops, Line 2 is listed twice,',
' let''s delete the line at the cursor postion');
GotoXY(1,3);
ReadKey;
DelLine;
GotoXY(1,10);
end.
6 楼
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:46:00
8、Procedure GotoXY (X: Byte; Y: Byte);
光标移动到(x,y)处,x指横坐标,y指纵坐标(从窗口顶部开始不包括标题栏)。
原来的位置(程序编译后一运行时)是(1,1),窗口的左上角。
例子:
Program Example6;
uses Crt;
{ Program to demonstrate the GotoXY function. }
begin
ClrScr;
GotoXY(10,10);
Write('10,10');
GotoXY(70,20);
Write('70,20');
GotoXY(1,22);
end.
7 楼
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:47:00
9、Procedure HighVideo;
高亮显示文本(不是窗口中的所有文本,执行该过程后,读入输出的文本才高亮
显示)它设置的视频属性高强度位。
例子:
Program Example14;
uses Crt;
{ Program to demonstrate the LowVideo, HighVideo, NormVideo functions. }
begin
LowVideo;
WriteLn('This is written with LowVideo');
HighVideo;
WriteLn('This is written with HighVideo');
NormVideo;
WriteLn('This is written with NormVideo');
end.
8 楼
小勇士来了2 [专家分:850] 发布于 2012-01-29 19:48:00
10、Procedure InsLine;
InsLine在当前光标位置插入一个空行,当前行以下的自动向下滚动一行,最后
一行从窗口中消失,光标不移动。
例子:
Program Example10;
uses Crt;
{ Program to demonstrate the InsLine function. }
begin
ClrScr;
WriteLn;
WriteLn('Line 1');
WriteLn('Line 3');
WriteLn;
WriteLn('Oops, forgot Line 2, let''s insert at the cursor postion');
GotoXY(1,3);
ReadKey;
InsLine;
Write('Line 2');
GotoXY(1,10);
end.
9 楼
小勇士来了2 [专家分:850] 发布于 2012-01-30 16:12:00
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
until KeyPressed;
{ The key is not Read,
so it should also be outputted at the commandline}
end.
12、Procedure LowVideo;
低亮度显示文本。
10 楼
小勇士来了2 [专家分:850] 发布于 2012-01-30 16:12:00
为什么没人顶?
我来回复