procedure TForm1.btn1Click(Sender: TObject); begin {$Define ss} (* 用于定义一个条件符号,一旦定义,条件符号就为真 *) {$IFDEF ss} (* 对条件符号进行判断,为真则编译源文件 *) ShowMessage('ss Has defined!!'); Text := 'ss Has defined!!'; Form1.Color := clLime; {$ELSE} (* 与$IFDEF配合使用,如果$IFDEF条件为假,则只对源文件$ELSE后一小部分进行编译 *) ShowMessage('ss Has not defined!!'); Text := 'ss Has NOT defined!!' Form1.Color := clRed; {$ENDIF} (* 结束一个以$IF开始的条件段 *)
{$UNDEF ss} (* 撤消以前的条件符号定义 *)
{$IFDEF ss} (* 因为已经撤销ss的定义 *) ShowMessage('ss Has defined!!'); Text := 'ss Has defined!!'; Form1.Color := clLime; {$ELSE} ShowMessage('ss Has not defined!!'); (* 因此,将执行以下语句 *) Text := 'ss Has NOT defined!!'; Form1.Color := clRed; {$ENDIF}
end;
|
请发表评论