刚把Delphi6从入门到精通看了一点。不知道那些预处理命令应该在什么时候用,就是比如{$IF}...{$IFEND},{$IFDEF}...{$ENDIF}等等这些个东西不知在什么情况下用,书上只是提到使用是应该有节制。
    请高手指教,谢谢谢谢!!!

解决方案 »

  1.   

    Two basic conditional compilation constructs closely resemble Pascal's if statement. The first construct{$IFxxx}
      ...
    {$ENDIF}causes the source text between {$IFxxx} and {$ENDIF} to be compiled only if the condition specified in {$IFxxx} is True. If the condition is False, the source text between the two directives is ignored.The second conditional compilation construct:{$IFxxx}
      ...
    {$ELSE}
      ...
    {$ENDIF}causes either the source text between {$IFxxx} and {$ELSE} or the source text between {$ELSE} and {$ENDIF} to be compiled, depending on the condition specified by the {$IFxxx}.Here are some examples of conditional compilation constructs:{$IFDEF Debug}
     Writeln('X = ', X);
    {$ENDIF}
    {$IFDEF WIN32}
     P := SmallPointToPoint(Message.Pos);
    {$ELSE}
     P := Message.Pos;
    {$ENDIF}You can nest conditional compilation constructs up to 16 levels deep. For every {$IFxxx}, the corresponding {$ENDIF} must be found within the same source file, which means there must be an equal number of {$IFxxx}'s and {$ENDIF}'s in every source file.
      

  2.   

    条件语句。
    类似if .... end;
    以后你用到了就知道了
    具体用法楼上的: cg1120已经写了。主要是在你设定条件判断的时候用吧。