Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Compound IFF Statement

samintz

Scott Mintz
May
1,582
27
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
 
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
 
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:\>
 
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.
 
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.
 

Similar threads

Back
Top