主题:TP下有清屏的函数吗?
只在乎你
[专家分:560] 发布于 2005-10-30 23:09:00
如题,类似TC的clrscr()
回复列表 (共14个回复)
沙发
liangqingzhi [专家分:130] 发布于 2005-10-31 09:44:00
uses crt;
...
clrscr;
板凳
只在乎你 [专家分:560] 发布于 2005-11-01 16:34:00
我在TP7.0下运行下面的程序
program aa;
uses crt;
begin
clrscr;
end;
编译通过了,但运行时刻出现错误,请问是什么原因啊????
3 楼
幽游の白玉 [专家分:140] 发布于 2005-11-01 20:59:00
是啊`~~~~我也正郁闷呢~~~想上论坛来寻求解答 没想到已经有兄弟提出了
4 楼
liangqingzhi [专家分:130] 发布于 2005-11-02 10:05:00
主要是crt.dcu文件太旧,在现在一些新电脑上使用会出错。将下面代码保存为_crt.pas,再编译成_crt.dcu放在..\TP\units\目录下
使用时:
uses _crt;
clrscr;
代码如下:
unit _crt;
interface
type st=set of char;
procedure setcursor(top,bottom:byte);
procedure cursoroff;
procedure cursoron;
function presskey:byte;
function keypressed:boolean;
procedure clrscr;
function wherex:byte;
function wherey:byte;
procedure gotoxy(x,y:byte);
function readkey:char;
function readchar(var c:char):byte;
function inputkey(c:char;s:st):char;
procedure MouseInit;
procedure GetMouseLeftClick(var x,y:integer);
procedure SetMouse(x,y:integer);
implementation
procedure setcursor;
begin
asm
mov ah,1
mov ch,top
mov cl,bottom
int 10h
end
end;
procedure cursoroff;
begin setcursor(32,32) end;
procedure cursoron;
begin setcursor(6,7) end;
function presskey;
var a:byte;
begin
asm
mov ah,2
int 16h
mov a,al
end;
presskey:=a
end;
function keypressed;
var a:boolean;
begin
asm
mov ah,1
int 16h
lahf
not ah
and ah,40h
mov a,ah
end;
keypressed:=a
end;
procedure clrscr;
begin
gotoxy(0,0);cursoroff;
write(' ':80*25);cursoron
end;
function wherex;
var x:byte;
begin
asm
mov bh,0
mov ah,3
int 10h
mov x,dl
end;
wherex:=x
end;
function wherey;
var y:byte;
begin
asm
mov bh,0
mov ah,3
int 10h
mov y,dh
end;
wherey:=y
end;
procedure gotoxy;
begin
asm
mov bh,0
mov dl,x
mov dh,y
mov ah,2
int 10h
end
end;
function readkey;
var r:char;
begin
asm
mov ah,8
int 21h
mov r,al
end;
readkey:=r
end;
function readchar;
var c0:char;s:byte;
begin
asm
mov bh,0
mov ah,8
int 10h
mov c0,al
mov s,ah
end;
c:=c0;
readchar:=s;
end;
function inputkey;
var k:char;
begin
repeat
k:=readkey;
if k=#0 then readkey
until (k in s)or (k=#13);
if k=#13 then inputkey:=c else inputkey:=k;
end;
procedure MouseInit;
begin
asm
mov ax,0
int 33h
mov ax,1
int 33h
end;
end;
procedure GetMouseLeftClick;
var mx,my,b:word;
begin
repeat
asm
mov ax,3
int 33h
mov b,bx
end;
until b=1;
repeat
asm
mov ax,3
int 33h
mov b,bx
mov mx,cx
mov my,dx
end;
until b=0;
x:=mx;y:=my;
end;
procedure SetMouse;
begin
asm
mov ax,4
mov cx,x
mov dx,y
int 33h
end
end;
end.
5 楼
xpycc [专家分:410] 发布于 2005-11-02 11:09:00
楼上的,强!
6 楼
幽游の白玉 [专家分:140] 发布于 2005-11-02 20:21:00
上2楼的`~
我还是不明白呀`~~为什么要先保存为.pas的格式~~再编译成.dcu的`~~~?
什么意思~~
7 楼
绿步甲 [专家分:1610] 发布于 2005-11-04 20:25:00
就是自己做个CRT单元.
但偶不明白,2楼你这个代码哪搞的,太太太太...强了~!~!~!~
8 楼
绿步甲 [专家分:1610] 发布于 2005-11-04 20:27:00
其实,下载补丁好了:http://www.mydrs.org/program/list.asp?id=136
9 楼
chty [专家分:230] 发布于 2005-11-18 16:21:00
四楼的真弓虽!!……
10 楼
小田甜 [专家分:3910] 发布于 2005-11-18 18:36:00
uses graph;
var
Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ' ');
if GraphResult <> grOk then
Halt(1);
closegraph;
end.
我来回复