谁能说出{$DEFINE}是啥意思?立即给分!

zhuxiaozhong 2003-09-15 09:15:36
谁能说出{$DEFINE}是啥意思?
...全文
45 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
空中居士 2003-09-15
  • 打赏
  • 举报
回复
看来一分都不容易得,学习来了。
liuhelin 2003-09-15
  • 打赏
  • 举报
回复
不想给分就算了
还立即给分!
kangji 2003-09-15
  • 打赏
  • 举报
回复
条件编译
idilent 2003-09-15
  • 打赏
  • 举报
回复
为什么我知道的分都这么少?

哈哈

idilent 2003-09-15
  • 打赏
  • 举报
回复
Defines a conditional symbol with the given name. The symbol is recognized for the remainder of the compilation of the current module in which the symbol is declared, or until it appears in an {$UNDEF name} directive. The {$DEFINE name} directive has no effect if name is already defined.

我认为是delphi比较高级的功能,使用该语句可以替代program/options/directorys and conditionals中的条件定义。

参考
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
{$define test}//you can disable and enable this line to see what happen.you must rebuild the project after you change it
procedure TForm1.Button1Click(Sender: TObject);
begin

{$ifdef test}
ShowMessage('define');
{$endif}
end;

end.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧