Compound IFF Statement

samintz

Scott Mintz
May 20, 2008
1,271
11
Solon, OH, USA
#1
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
 

samintz

Scott Mintz
May 20, 2008
1,271
11
Solon, OH, USA
#2
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
 
#4
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:\>
 

samintz

Scott Mintz
May 20, 2008
1,271
11
Solon, OH, USA
#7
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.