9

我有许多包含许多条件指令块的单元,例如:

{$IFDEF DELPHI6ANDLOWER}
  *Do something 1*
{$ELSE}
  *Do something 2*
{$ENDIF}

现在,我决定放弃对 Delphi 6 (VER140) 和更低版本的支持。

有没有可以施展魔法的工具?希望上面的代码变成:

  *Do something 2*

我已经测试过 ModelMaker、CnPack、GExperts,但没有一个能做到这一点。

4

2 回答 2

16

Delphi Inspiration 的免费软件程序 DIPP 可以删除条件。

http://www.yunqa.de/delphi/doku.php/products/dipp/index

于 2012-10-16T18:48:25.890 回答
4

首先,我确认@ctomita提到的DIPP工具非常适合我的情况。

其次,我认为与人们分享我如何使用该工具来解决我的案例可能很有用。

测试1.通过

//--------------------------------------
{$IFDEF ONE}
  ShowMessage('If ONE was defined');
  WriteLn('If ONE was defined');
  {$IFDEF ONE_ONE}
    ShowMessage('If ONE_ONE was defined');
    WriteLn('If ONE_ONE was defined');
  {$ENDIF}
{$ELSE}
  ShowMessage('If ONE was not defined');
  WriteLn('If ONE was not defined');
{$ENDIF}
//--------------------------------------
{$IFNDEF ONE}
  ShowMessage('If ONE was not defined');
  WriteLn('If ONE was not defined');
{$ELSE}
  ShowMessage('If ONE was defined');
  WriteLn('If ONE was defined');
{$ENDIF}
//--------------------------------------

ONE要从Test1.pas中删除所有条件块,并假设好像有一个名为ZERO当前定义的条件符号,请使用命令提示符中的以下命令:

dipp -o -c -dZERO -h-ONE "Test1.pas" "Test1_output.pas"

Test1_output.pas

//--------------------------------------

  ShowMessage('If ONE was not defined');
  WriteLn('If ONE was not defined');

//--------------------------------------

  ShowMessage('If ONE was not defined');
  WriteLn('If ONE was not defined');

//--------------------------------------

请注意,当-c指定选项时,DIPP 会跳过由未定义条件包围的代码,根据定义的条件插入包含文件。换句话说,DIPP 像编译器一样处理源代码。

于 2012-10-17T18:36:47.930 回答