pp4d
[id:lethevert:20050915:p4]
だんだん、できてきましたよ。
あとクラスのメソッドの本体部分の記述ができれば、ひとまず、使える状態になる。
ただ、サンプルだけを見ても、何をやっているのかいまいち分からないから、何が楽しいのか不明かも。
-
-
- -
-
いまは何を書いているか分かるけど、時間を置いて見直したら、解読できるかなぁ・・・、というような感じになってきました。どこかのタイミングで整理しないと。
JavaやDelphiで書くよりも、Cleanで書くほうがごちゃごちゃするような気がするけど、密度が濃いからかな。あと、例外処理をきれいに書く方法を見つける必要があるな。
-
-
- -
-
こういうソースを用意すると、
// // This is sample unit. // unit Sample (* インターフェースの前のコメント *) INTerFace uses SysUtils type TArrString = array of string; TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Label1: TLabel; Label2: TLabel; private FName: string; procedure SetName(Name: string); public property Name array of string read FName write SetName; end; //procedure Sample(i:Integer; j:Integer) -> string forward var Form1: TForm1; implementation var Form2: TForm2 a,b,c: Integer = 1 (* コメント *) procedure Sample(i, j:Integer; s1 : string) -> string var str: String; //i: Integer begin str := 'sample' FOR i := 0 to $1F do // begin str := str + IntToStr(i) if i > 5 then str := str + #13#10; i=i+1; Else str := str + '###' + #13#10 i=i+1;Result := str end function Sample2; begin From1 := TForm1.Create end end.
こういう風に変換します。
unit Sample; interface uses SysUtils; type TArrString: array of string; TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Label1: TLabel; Label2: TLabel; private FName: string; procedure SetName(Name: string); public property Name: array of string read FName write SetName; end; var Form1: TForm1; implementation type var Form2: TForm2; a: Integer = 1; b: Integer = 1; c: Integer = 1; function Sample(i: Integer; j: Integer; s1: string): string; forward; procedure Sample2; forward; function Sample(i: Integer; j: Integer; s1: string): string; var str : String; begin str := 'sample'; FOR i := 0 to $1F do begin str := str + IntToStr ( i ); if i > 5 then begin str := str + #13#10; i = i + 1; end Else begin str := str + '###' + #13#10; end; end; i = i + 1; Result := str; end; procedure Sample2; begin From1 := TForm1 . Create; end; end.