IF Evaluates conditional operations in script files. Format IF [NOT] [WARN | ERROR | FAIL] [ EQ| GT | GE ] [VAL] [EXISTS ] Template NOT/S,WARN/S,ERROR/S,FAIL/S,EQ/K,GT/K,GE/K,VAL/S,EXISTS/K Location Internal In a script file, IF, when its conditional is true, carries out all the subsequent commands until an ENDIF or ELSE command is found. IF must be used in conjunction with ENDIF, however, ELSE is optional. When the conditional is not true, execution skips directly to the ENDIF or to an ELSE. The conditions and commands in IF and ELSE blocks can span more than one line before their corresponding ENDIFs. Nested Ifs jump to the matching ENDIF. The additional keywords are as follows: NOT Reverses the interpretation of the result. WARN True if previous return code is greater than or equal to 5. ERROR True if previous return codes is greater than or equal to 10; only available if FAILAT is set to greater than 10. FAIL True if previous return code is greater than or equal to 20; only available if FAILAT is set to greater than 20. GT True if the test of a is greater than the text of b (disregarding case). Use NOT GT for less than. GE True if the text of a is greater than or equal to the text of b (disregarding case). Use NOT GE for less than or equal to. EQ True if the text of a and b is identical (disregarding case). VAL Specifies a numeric comparison. EXISTS True if the file exists. If more than one of the three condition-flag keywords (WARN, ERROR, FAIL) are given, the one with the lowest value is used. You can use local or global variables with IF by prefacing the variable name with a $ character. Example 1: IF EXISTS Work/Prog TYPE Work/Prog HEX ELSE ECHO "It's not here" ENDIF AmigaDOS displays the file Work/Prog if it exists in the current directory. Otherwise, AmigaDOS displays the message It's not here and continues after the ENDIF. Example 2: IF ERROR SKIP errlab ENDIF ECHO "No error" LAB errlab If the previous command produces a return code greater than or equal to 10, AmigaDOS skips over the ECHO command to the errlab label. See also: EXECUTE, FAILAT, LAB, QUIET, SKIP. For more examples using the IF command, see Chapter 8.