2012-07-06 4 views
1

TEdit 컨트롤의 내용을 파일에 저장하는 작은 프로그램을 작성하고 있습니다.닫기를 사용할 때 매개 변수의 수가 잘못되었습니다.

아이디어는 사용자가 TEdit 컨트롤에 뭔가를 쓰고 디스크에 파일을 쓰려면 버튼을 누르지 만 컴파일하려고하면 "unit1.pas (37,15)"오류가 발생합니다. 오류 : 호출 할 매개 변수의 개수가 잘못 지정되었습니다. "닫기" "

내 양식에는 TEdit 컨트롤과 TButton 만 있습니다.

var 
    Form1: TForm1; 
    f: text; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
    writeln (f,Edit1.Text); 
    close (f); 
end; 

Begin 
    assign (f,'code.txt'); 
    rewrite (f); 
end. 

도대체 내가 잘못하고있는 것은 무엇입니까 ??? 조금 인터넷 검색으로

+2

당신이'사용해야 발견 CloseFile' 대신 – RRUZ

+0

@RRUZ : 완벽하게 작동하는, 감사합니다. – Ashir

답변

4

나는이

Close exists in both System unit (implicitly used) and TCustomForm (TForm ancestor) class. Pascal identifier scoping rules makes unqualified Close takes the inner most scope. Therefore, if you call it in a TForm method, then it's TForm's Close that gets called. To avoid this, either use qualified call (System.Close to call the one from System unit or Self.Close to call the one belonging to current form) or CloseFile (which actually just calls System.Close) from ObjPas unit (automatically used in {$mode objfpc} or {$mode delphi}).

+0

감사합니다. CloseFile은 완벽하게 작동합니다. – Ashir

관련 문제