我有许多使用相同单元的 Delphi 10 项目,我们称它们为“commons”。
当我向公共资源添加新单元时,我必须手动将其添加到每个项目中。我尝试在每个文件的部分添加{$INCLUDE commons.inc}一行:uses.dpr
uses
Forms,
{$INCLUDE commons.inc}
projectUnit1,
...;
Run Code Online (Sandbox Code Playgroud)
commons.inc有这样的内容:
common1,
common2,
Run Code Online (Sandbox Code Playgroud)
我可以编译项目,但无法管理commons.inc. 我所说的管理是指Ctrl-F12从项目中删除等。
这是来自Delphi的帮助:
使用包含文件有一个限制:不能在语句部分的中间指定包含文件。事实上,语句部分开始和结束之间的所有语句必须存在于同一个源文件中。
我想这就是为什么我的想法行不通的原因?
我做错了什么,还是有其他解决方案?
在该Data.DB单元中,声明了以下枚举:
TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord, ftBoolean, ftFloat, ...)
Run Code Online (Sandbox Code Playgroud)
我需要确定DataType搜索网格中的字段是否是整数、字符串、浮点数、日期、blob 等。
Integer 应该是任何可以用作整数的类型,例如ftSmallint、ftInteger、ftWord等。
有没有比下面更短的方法来做到这一点?
if (Field.DataType = ftInteger) or (Field.DataType = ftSmallint) or (Field.DataType = ftWord) then Result := ftInteger;
Run Code Online (Sandbox Code Playgroud)