迷你5207专属论坛

注册

 

发新话题 回复该主题

[设计] [delphi]with的秒用 [复制链接]

发表者
使用with的时候有时会得到很不错的效果。下面举个例子大家看看:
  1. //先申明一个记录类型
  2.   TProjectData = record
  3.     FProjectID: string;
  4.     FName: string;
  5.     FCode: string;
  6.     FAddress: string;
  7.     FInvestor: string;
  8.     FInvestManager: string;
  9.     FWriteUnit: string;
  10.     FWritor: string;
  11.     FWriteDate: string;
  12.     FBuildArea: string;
  13.     FBidManager: string;
  14.     FBidDate: string;
  15.     FStartDate: string;
  16.     FEndDate: string;
  17.     FRemark: string;
  18.     FUpperLimit: double;
  19.     FVersion: string;
  20.     FCreateDate: TDateTime;
  21.     FModifyDate: TDateTime;
  22.     FJZYSJE: double;
  23.   end;

  24.   //使用with的时候有时会得到很不错的效果。下面举个例子大家看看:
  25.   //这里使用with就可以带省大量的代码篇幅,即明了又简洁。
  26.   //这样就不用在每个引用前加个"FProjectData."了,不是很爽吗?
  27.   with FProjectData do
  28.   begin
  29.     sSQL := Format(sSelectSQL, [FProjectID, FName,
  30.                   ,FCode,FAddress,FInvestor,FInvestManager
  31.                   ,FWriteUnit,FWritor,FWriteDate,FBuildArea
  32.                   ,FBidManager,FBidDate,FStartDate,FEndDate
  33.                   ,FRemark,FUpperLimit,FVersion,FCreateDate
  34.                   ,FModifyDate, FJZYSJE]);
  35.   end;
复制代码
本主题由 皇帝 5207 于 2009-7-3 23:07:56 执行 主题分类 操作
分享 转发
相信与不相信都是矛盾的.  5207宣!欢迎您来到点滴论坛
TOP
沙发

回复:[delphi]with的秒用

兄弟,标题里有错别字。。。
我们都在人生的舞台上笨拙地舞蹈着,并自得其乐。
----
Tel : 13655310832
TOP
凳子

回复:[delphi]with的秒用

兄弟,标题里有错别字。。。
我们都在人生的舞台上笨拙地舞蹈着,并自得其乐。
----
Tel : 13655310832
TOP
发新话题 回复该主题