摘要: 本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Button1: TBu... 阅读全文
posted @ 2008-03-18 23:58 万一 阅读(4066) 评论(4) 推荐(1)
摘要: 首先, 上一个例子, 用数组也可以实现, 并且更简单: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: ... 阅读全文
posted @ 2008-03-18 23:24 万一 阅读(3748) 评论(10) 推荐(1)
摘要: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton... 阅读全文
posted @ 2008-03-18 14:23 万一 阅读(3726) 评论(3) 推荐(2)
摘要: 如果 Pos 函数的第一个参数是 Char 而非 String, 那么编译器也会先把 Char 转换为 String; 从内存结构到管理机制, String 远比 Char 要复杂. 因此, 面对这种情况(要定位的是 Char) Pos 还有优化的余地; 优化后速度会提升 5 倍左右. 测试效果图: unit Unit1; interface uses Windows, Mess... 阅读全文
posted @ 2008-03-18 12:53 万一 阅读(3758) 评论(2) 推荐(2)
摘要: 如果参数在函数中不可能修改, 一定要使用 const; 不然, 编译器就会: 假定先修改, 先要备份; 使用前后要增减引用计数; 还要套上 try finally. 指定了 const 就可以避免以上过程从而提高效率. 测试效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes... 阅读全文
posted @ 2008-03-18 10:55 万一 阅读(3249) 评论(6) 推荐(2)