폼이 없는 유닛 코딩
unit Unit2;
interface
function Test_FC(j : string) : integer;
procedure Test_PD();
var
i : string;
implementation
uses unit1;
procedure Test_PD();
begin
i:=Form1.Edit1.Text;
Test_FC(i);
case Test_FC(i) of
1:
begin
Form1.label1.caption:='S';
end;
2:
begin
Form1.label1.caption:='F';
end;
end;
function Test_FC(j : string): integer;
begin
if i='1' then
begin
Test_FC:=1;
end
else
begin
Test_FC:=2;
end;
end;
end.
그런데 프로시저는 문제가 없는데 함수에서 에러가 뜹니다.
에러 메세지:statments expected but 'function' found
case문에서 end;가 빠졌네요...
case Test_FC(i) of
1:
begin
Form1.label1.caption:='S';
end;
2:
begin
Form1.label1.caption:='F';
end;
end; <<<<<<<<<<<<<<<<<<<<< 추가
위와같이 한줄짜리는 begin ~ end로 안묶어도 됩니다....
case Test_FC(i) of
1: Form1.label1.caption:='S';
2: Form1.label1.caption:='F';
end;
^^ 항상 즐코하세요.
김태영 wrote:
> 폼이 없는 유닛 코딩
> unit Unit2;
>
> interface
> function Test_FC(j : string) : integer;
> procedure Test_PD();
>
>
> var
> i : string;
>
> implementation
>
> uses unit1;
>
> procedure Test_PD();
> begin
> i:=Form1.Edit1.Text;
> Test_FC(i);
> case Test_FC(i) of
> 1:
> begin
> Form1.label1.caption:='S';
> end;
> 2:
> begin
> Form1.label1.caption:='F';
> end;
>
>
> end;
>
> function Test_FC(j : string): integer;
> begin
> if i='1' then
> begin
> Test_FC:=1;
> end
> else
> begin
> Test_FC:=2;
> end;
> end;
>
>
> end.
>
> 그런데 프로시저는 문제가 없는데 함수에서 에러가 뜹니다.
> 에러 메세지:statments expected but 'function' found