1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How .AND. and .OR. are evaluated?

Discussion in 'Support' started by jbanaszczyk, Sep 12, 2014.

  1. jbanaszczyk

    Joined:
    Jun 8, 2013
    Messages:
    98
    Likes Received:
    0
    I have a short question.

    How logical operators are evaluated? Does evaluation stops when the result is known (like && in C)? Or whole expression is evaluated?
    From left to right?

    (it could be checked with two user defined functions, but unfortunately now I have no access to full TCC)

    best regards.
     
  2. AnrDaemon

    Joined:
    Aug 23, 2010
    Messages:
    51
    Likes Received:
    1
    Hint: @EXECSTR…
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,036
    Likes Received:
    84
    The parser has to evaluate the entire line. Only the DWIM parser knows what combination of operators you might tack on at the end of the line ...
     
  4. jbanaszczyk

    Joined:
    Jun 8, 2013
    Messages:
    98
    Likes Received:
    0
    @AnrDaemon - thanks

    ----------
    @rconn: Hmm. I'm not asking for artificial intelligence

    Code:
    Set fName=C:\xyz
    If "%@Left[2,%fName]" == "D:" .AND. exist %fName BlahBlah
    
    can be written as
    Code:
    Set fName=C:\xyz
    If "%@Left[2,%fName]" == "D:" If exist %fName BlahBlah
    
    In the second case filesystem will not be checked.
     

Share This Page