摘要:
//要点16: 在实现区(implementation), 自定义的方法是有顺序的 function MyFunA(x: Integer): Integer; begin Result := Sqr(x); {取平方} //MyFunB(x); {前面的函数不能调用后面的函数} end; funct 阅读全文
posted @ 2020-04-20 17:18
范思哲
阅读(135)
评论(0)
推荐(0)
摘要:
//要点15: 调用其他单元的函数 //包含函数的单元: unit Unit2; interface function MyFun(x,y: Integer): Integer; {函数必须在接口区声明} implementation function MyFun(x,y: Integer): In 阅读全文
posted @ 2020-04-20 17:08
范思哲
阅读(141)
评论(0)
推荐(0)
摘要:
//要点14: 如果声明在 TForm1 类内, 那它就是 TForm1 类的一个方法了 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dia 阅读全文
posted @ 2020-04-20 17:06
范思哲
阅读(248)
评论(0)
推荐(0)
摘要:
//要点13: 需要给其他单元调用, 必须在 interface 声明, 但必须在 uses 区后面 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Form 阅读全文
posted @ 2020-04-20 16:57
范思哲
阅读(415)
评论(0)
推荐(0)
摘要:
//要点12: implementation 区中的过程或函数, 只能在本单元调用 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialog 阅读全文
posted @ 2020-04-20 16:53
范思哲
阅读(209)
评论(0)
推荐(0)
摘要:
//要点11: 参数可以分为: 默认参数(传值)、var(传址)、out(输出)、const(常数)四类 {默认参数是传值, 不会被改变} function MyF1(x: Integer): Integer; begin Inc(x); Result := x; end; {var参数是传址, 会 阅读全文
posted @ 2020-04-20 16:51
范思哲
阅读(202)
评论(0)
推荐(0)
摘要:
//要点10: 过程和函数都可以有一个或多个默认参数; 但必须在非默认参数后面 function MyFun(s1: string; s2: string='好人'): string; begin Result := s1 + s2; end; {调用} procedure TForm1.Butto 阅读全文
posted @ 2020-04-20 16:48
范思哲
阅读(125)
评论(0)
推荐(0)
摘要:
//要点9: 没有参数的过程或函数, 在调用时可以省略 (); 也可以带着 function MyFun: string; begin Result := 'ok'; end; {调用} procedure TForm1.Button1Click(Sender: TObject); var s: s 阅读全文
posted @ 2020-04-20 16:46
范思哲
阅读(200)
评论(0)
推荐(0)