1个子界的例子
1 unit Unit1;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls;
8
9 type
10 TForm1 = class(TForm)
11 Button1: TButton;
12 Button2: TButton;
13 Button3: TButton;
14 procedure Button1Click(Sender: TObject);
15 procedure Button2Click(Sender: TObject);
16 procedure Button3Click(Sender: TObject);
17 private
18 { Private declarations }
19 public
20 { Public declarations }
21 end;
22
23 var
24 Form1: TForm1;
25
26 implementation
27
28 {$R *.DFM}
29 // 子界
30 // 序例程
31 //ordinal routines
32 procedure TForm1.Button1Click(Sender: TObject);
33 type
34 tc='a'..'z';
35 var
36 c:tc;
37 oi:integer;
38 pi,si:char;
39 s:string;
40 begin
41 c:='f';
42 oi:=ord(c);
43 pi:=pred(c);
44 si:=succ(c);
45 s:=
46 'sx:'+inttostr(oi)+#13+
47 'pred:'+pi+#13+
48 'succ:'+si;
49 showmessage(s);
50 end;
51
52 procedure TForm1.Button2Click(Sender: TObject);
53 type
54 zj='a'..'z';
55 var
56 i:zj;
57 b:string;
58 begin
59 i:='b';
60 i:=pred(i);
61 b:=i;
62 showmessage(b);
63 end;
64 procedure TForm1.Button3Click(Sender: TObject);
65 type
66 Tsize=(a,b,c);
67 var
68 size:Tsize;
69 zy:word;
70 begin
71 size:=a;
72 zy:=15;
73 showmessage(inttostr(ord(size)));
74 showmessage(inttostr(zy));
75 end;
76 end.
77
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls;
8
9 type
10 TForm1 = class(TForm)
11 Button1: TButton;
12 Button2: TButton;
13 Button3: TButton;
14 procedure Button1Click(Sender: TObject);
15 procedure Button2Click(Sender: TObject);
16 procedure Button3Click(Sender: TObject);
17 private
18 { Private declarations }
19 public
20 { Public declarations }
21 end;
22
23 var
24 Form1: TForm1;
25
26 implementation
27
28 {$R *.DFM}
29 // 子界
30 // 序例程
31 //ordinal routines
32 procedure TForm1.Button1Click(Sender: TObject);
33 type
34 tc='a'..'z';
35 var
36 c:tc;
37 oi:integer;
38 pi,si:char;
39 s:string;
40 begin
41 c:='f';
42 oi:=ord(c);
43 pi:=pred(c);
44 si:=succ(c);
45 s:=
46 'sx:'+inttostr(oi)+#13+
47 'pred:'+pi+#13+
48 'succ:'+si;
49 showmessage(s);
50 end;
51
52 procedure TForm1.Button2Click(Sender: TObject);
53 type
54 zj='a'..'z';
55 var
56 i:zj;
57 b:string;
58 begin
59 i:='b';
60 i:=pred(i);
61 b:=i;
62 showmessage(b);
63 end;
64 procedure TForm1.Button3Click(Sender: TObject);
65 type
66 Tsize=(a,b,c);
67 var
68 size:Tsize;
69 zy:word;
70 begin
71 size:=a;
72 zy:=15;
73 showmessage(inttostr(ord(size)));
74 showmessage(inttostr(zy));
75 end;
76 end.
77


浙公网安备 33010602011771号