[Toc][Index]

IFF - IF / THEN / ELSE conditional command execution

 
 Purpose:    Perform IF / THEN / ELSE conditional execution of commands. 
             
 Format:     IFF [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition 
             ...] THEN & commands 
             [ELSEIFF condition THEN & commands ] ... 
             [ELSE & commands ] 
             & ENDIFF 
             
             condition :  A test to determine if the command(s) should be 
             executed. 
             commands :  One or more commands to execute if the 
             condition(s) is true.  If you use multiple commands, they 
             must be separated by command separators or be placed on 
             separate lines of a batch file. 
 
 See also:  IF and @IF. 
 Usage 
 IFF is similar to the IF command, except that it can perform one set of 
 commands when a condition or set of conditions is true and different 
 commands when the conditions are false. 
 IFF can also execute multiple commands when the conditions are true or 
 false; IF normally executes only one command.  IFF imposes no limit on 
 the number of commands and is generally a "cleaner" and more structured 
 command than IF. 
 IFF is always followed by one or more conditions.  If they are true, the 
 commands that follow the word THEN are executed.  Additional conditions 
 can be tested with ELSEIFF.  If none of these conditions are true, the 
 commands that follow the word ELSE are executed.  After the selected 
 commands (if any) are executed, processing continues after the word 
 ENDIFF. 
 If you add a NOT before the condition, the THEN commands are executed 
 only when the condition is false and the ELSE commands are executed only 
 when the condition is true. 
 The commands may be separated by command separators, or may be on 
 separate lines of a batch file.  You should include a command separator 
 or a line break after a THEN, before an ELSEIFF, and before and after an 
 ELSE. 
 You can link conditions with .AND., .OR., or .XOR., and you can group 
 conditions with parentheses.  You can nest IFF statements up to 15 levels 
 deep.  The conditions can test strings or numbers, the existence of a 
 file or subdirectory, the errorlevel returned from the preceding external 
 command, and the existence of alias names and internal commands. 
 See the IF command for a list of the possible conditions, and details on 
 useing .AND., .OR., .XOR., and parentheses. 
 The commands can include any internal command, alias, external command, 
 or batch file. 
 The following batch file fragment tests the monitor type (monochrome or 
 color), and sets the appropriate colors and prompt (enter the "prompt" 
 lines on one line of the batch file): 

 
         iff "%_monitor" == "color" then
            color bright white on blue & cls
            prompt=$e[s$e[1;1f$e[41;1;37m$e[K  Path: $p$e[u$e[44;37m$n$g
         else
            prompt=$e[s$e[1;1f$e[0;7m$e[K  Path: $p$e[u$e[0m$n$g
         endiff
 
 
 The alias in this second example checks to see if the argument is a 
 subdirectory.  If so, the alias deletes the subdirectory's files and 
 removes it (enter this on one line): 

 
         [c:\] alias prune `iff isdir %1 then & del /sxz %1
               & else & echo Not a directory! & endiff`
 
 
 Be sure to read the cautionary notes about GOTO and IFF under the GOTO 
 command before using a GOTO inside an IFF statement. 
 If you pipe data to an IFF, the data will be passed to the command(s) 
 following the IFF, not to IFF itself. 

Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs