主题:怎么建立单元???
			 shisutianxia
				 [专家分:630]  发布于 2007-08-12 10:21:00
 shisutianxia
				 [专家分:630]  发布于 2007-08-12 10:21:00							
			UNIT源程序写好了,怎样搞成单元??高手帮忙!!!!!!
						
					 
		
			
回复列表 (共5个回复)
		
								
				沙发
				
					 abcwuhang [专家分:1840]  发布于 2007-08-12 18:50:00
abcwuhang [专家分:1840]  发布于 2007-08-12 18:50:00				
				unit 单元名;
interface
{函数名称}
implementation
{过程}
begin
end.
							 
						
				板凳
				
					 小田甜 [专家分:3910]  发布于 2007-08-13 03:00:00
小田甜 [专家分:3910]  发布于 2007-08-13 03:00:00				
				unit 单元名;
interface
{常量、类型、变量、函数、过程声明}
这里声明的可以被调用,函数、过程只需要写第一行,剩下的写在下面
implementation
在这里写的常量、类型、变量、函数、过程不能被外部程序调用。
并把上面声明的代码写清楚。
begin
这里写出初始化内容,如果没有上面的那个begin可以省略。
end.
举一例:
[quote]unit bmp;
interface
    uses graph;
    const
      maxx=19;maxy=9;
    var
      x,y:byte;
    procedure BMP16(path:string;x,y:integer;vscolor:byte);
    procedure inigraph;
implementation
  procedure inigraph;
    var
      grDriver: Integer;
      grMode: Integer;
      ErrCode: Integer;
  begin
    grDriver := Detect;
{$IFDEF Use8514}                          { check for Use8514 $DEFINE }
    GrDriver := IBM8514;
    GrMode := IBM8514Hi;
{$ELSE}
    GrDriver := Detect;                { use autodetection }
{$ENDIF}
    InitGraph(GrDriver, GrMode, '');
    ErrCode := GraphResult;
    if ErrCode <> grOk then begin
      Writeln('Graphics error:', GraphErrorMsg(ErrCode));
      halt(1);
    end;
  end;
procedure BMP16(path:string;x,y:integer;vscolor:byte);
  const
    color16:array [0..15] of byte
      =(0,4,2,6,1,5,3,8,7,12,10,14,9,13,11,15);
  var
    fin:text;
    width,height,f:word;
    a:array [1..2] of byte;
    n,k,r:byte;
    i,j,l:longint;
    c:char;
begin
  assign(fin,path);
  reset(fin);
  for i:=1 to 10 do read(fin,c);
  f:=0;
  for j:=1 to 4 do begin
    read(fin,c);f:=ord(c)*round(exp(ln(256)*(j-1)))+f;
  end;
  for i:=1 to 4 do read(fin,c);
  width:=0;
  for j:=1 to 4 do begin
    read(fin,c);width:=ord(c)*round(exp(ln(256)*(j-1)))+width;
  end;
  height:=0;
  for j:=1 to 4 do begin
    read(fin,c);height:=ord(c)*round(exp(ln(256)*(j-1)))+height;
  end;
  reset(fin);r:=0;
  for i:=1 to f do read(fin,c);
  i:=1;j:=1;
  while (i<=height) do begin
    read(fin,c);r:=(r+1) mod 4;
    n:=ord(c);
    a[1]:=n div 16;
    a[2]:=n mod 16;
    for k:=1 to 2 do begin
      if (x+j-1>=0) and (x+j-1<=getmaxx) and (y+height-i>=0) and (y+height-i<=getmaxy) then
      if color16[a[k]]<>vscolor then putpixel(x+j-1,y+height-i,color16[a[k]]);
      j:=j+1;if j>width then break;
    end;
    if j>width then begin
      j:=1;
      i:=i+1;
      if r<>0 then for l:=3 downto r do read(fin,c);
      r:=0;
    end;
  end;
  close(fin);
end;
end.
[/quote]
这个是我纸牌上的一个过程。
							 
						
				3 楼
				
					 游侠UFO [专家分:1200]  发布于 2007-08-13 12:41:00
游侠UFO [专家分:1200]  发布于 2007-08-13 12:41:00				
				我记得好像直接Alt+F9编译过后就可以生成单元文件了
							 
						
				4 楼
				
					 shisutianxia [专家分:630]  发布于 2007-08-13 17:34:00
shisutianxia [专家分:630]  发布于 2007-08-13 17:34:00				
				是不是还要先保存为****.tpu????
可还是没用?????????????
							 
						
									
			
我来回复