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

Compound IFF Statement

Discussion in 'Support' started by samintz, Jan 21, 2015.

  1. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11
    I cannot get this compound IFF statement to work.
    Code:
    iff (%fPersist == 1 .and. %fDel == 1) .or. ^
        ("%drive2" != "" .and. %fDel == 1) .or. ^
        ("%drive1" == "" .and. (%fDel==1 .or. %fPersist==1)) then
        goto :usage
    endiff
    
    Implemented as 3 statements it works correctly
    Code:
    iff %fPersist == 1 .and. %fDel == 1 then
        goto :usage
    endiff
    iff "%drive2" != "" .and. %fDel == 1 then
        goto :usage
    endiff
    iff    "%drive1" == "" .and. (%fDel==1 .or. %fPersist==1) then
        goto :usage
    endiff
    
     
  2. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11
    The idea behind the checks is I have a command line:
    Code:
    PSUBST [drive1: [drive2:]path] [/P]
    PSUBST drive1: /D | /P
    
    I cannot have both /D and /P specified
    if drive2 has been given, then /D is not allowed
    if /D or /P is given, then drive1 cannot be blank.

    Looks like I missed one too. if drive2 is missing, then either /P or /D must be present
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,021
    Likes Received:
    84
    Seems to be working OK here. What are the arguments you're passing when you see it fail?
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,058
    Likes Received:
    30
    The construction of the command seems OK. This similar BTM looks like it dies the right things.
    Code:
    v:\> type ifftest.btm
    iff (%1 == 1 .and. %2 == 1) .or. ^
      ("%4" != "" .and. %2 == 1) .or. ^
      ("%3" == "" .and. (%1==1 .or. %2==1)) then
      echo foo
    endiff
    
    v:\> ifftest.btm 1 1
    foo
    
    v:\> ifftest.btm 0 1 xx yy
    foo
    
    v:\> ifftest.btm 1 2
    foo
    
    v:\> ifftest.btm 0 1
    foo
    
    v:\> ifftest.btm 1 0 xx
    
    v:\>
     
  5. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11
    Hmm. The code I posted is what I used. When I separated it into 3 IFF statements it worked. As a compound statement it executed "goto :usage" every time.
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,021
    Likes Received:
    84
    Still works fine for me, either executing "goto" if something matched or falling out the bottom if it didn't. You haven't yet told me what your args are when it fails to work for you.
     
  7. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11
    Chalk it up to user error. I cannot reproduce it now. It was quite frustrating at the time however. I thought maybe it was due to the fact that the code was in a BAT file instead of a BTM file. Or some weird combination of spaces vs. tabs. But everything seems to work correctly today.
     

Share This Page