全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:957
推到 Plurk!
推到 Facebook!

Closefile 一問???

答題得分者是:shieh2700
TTS
初階會員


發表:72
回覆:66
積分:27
註冊:2003-05-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-31 18:13:23 IP:61.218.xxx.xxx 未訂閱
procedure Tform1.BitBtn1Click(Sender: TObject); var txfile: Textfile; begin AssignFile(txfile, stxtName); Reset(txfile); while Not Eof(txfile) do begin ReadLn(txfile, str); ........ end; CloseUseFile(txfile); end; procedure Tform1.CloseUseFile(AAA: ???); begin CloseFile(AAA); ...... end; 以上範例中的 CloseUseFile 是我自己寫的procedure 但是不知道這個procedure CloseUseFile(AAA: ???); 當中的key該如何定義? 麻煩指導一下!!!
shieh2700
高階會員


發表:0
回覆:127
積分:100
註冊:2002-06-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-12-31 18:33:06 IP:61.229.xxx.xxx 未訂閱
引言: procedure Tform1.BitBtn1Click(Sender: TObject); var txfile: Textfile; begin AssignFile(txfile, stxtName); Reset(txfile); while Not Eof(txfile) do begin ReadLn(txfile, str); ........ end; CloseUseFile(txfile); end; procedure Tform1.CloseUseFile(AAA: ???); begin CloseFile(AAA); ...... end; 以上範例中的 CloseUseFile 是我自己寫的procedure 但是不知道這個procedure CloseUseFile(AAA: ???); 當中的key該如何定義? 麻煩指導一下!!!
procedure Tform1.CloseUseFile(AAA: File);
begin
  CloseFile(AAA);
  ......
end;
發表人 - shieh2700 於 2004/12/31 18:59:55
TTS
初階會員


發表:72
回覆:66
積分:27
註冊:2003-05-06

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-12-31 19:09:06 IP:61.218.xxx.xxx 未訂閱
我有找到宣告的方式 procedure Tform1.CloseUseFile(var AAA: Textfile); begin CloseFile(AAA); ...... end; 但是當程式Run到CloseFile(AAA) 時會出現 '輸出入錯誤 103' 該如何解決呢???
TTS
初階會員


發表:72
回覆:66
積分:27
註冊:2003-05-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-12-31 19:27:02 IP:61.218.xxx.xxx 未訂閱
shieh2700 大大 你的方式不行耶 會出現 type Not allow here!!!
shieh2700
高階會員


發表:0
回覆:127
積分:100
註冊:2002-06-13

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-12-31 23:35:48 IP:61.229.xxx.xxx 未訂閱
抱歉, 先前的程式未經測試, 確實無法執行.    下列程式碼在 Delphi7 下可正常執行.    
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;    type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    procedure CloseUseFile(var f: TextFile);
    { Public declarations }
  end;    var
  Form1: TForm1;    implementation    {$R *.dfm}    procedure TForm1.Button1Click(Sender: TObject);
var
  f : TextFile;
  s : string;
begin
  if FileExists( 'C:\a.txt' ) then begin
    Memo1.Clear;
    AssignFile( f, 'C:\a.txt' );
    Reset( f );
    while NOT EOF(f) do begin
      ReadLn( f, s );
      Memo1.Lines.Add( s );
    end;
    CloseUseFile( f );
  end;
end;    procedure TForm1.CloseUseFile(var f: TextFile);
begin
  CloseFile( f )
end;    end.
系統時間:2024-06-26 9:30:22
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!