AmigaOS 4.0 - About OS4 - Commands
||Evaluates conditional operations in a script file.
IF [NOT] [WARN | ERROR | FAIL] [<string-a> EQ | GT | GE <string-b>]
[VAL] [EXISTS <filename>]
||NOT/S, WARN/S, ERROR/S, FAIL/s, EQ/K, GT/K, GE/K, VAL/S, EXISTS/K
In a script file, IF, when it conditional is true, carries out all of 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 to 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:
If more than one of the three condition-flag keywords (WARN, ERROR, FAIL) are given, the one with the lowest value is used.
||Reverses the interpretation of the result.
||True if previous return code is greater than or equal to 5.
True if previous return code is greater than or equal to 10; only available if FAILAT is set to greater than 10.
True if previous return code is greater than or equal to 20; only available if FAILAT is set to greater than 20.
|<a> GT <b>
True if the text of <a> is greater than the text of <b> (disregarding case). Use NOT GT for less than or
|<a> GE <b>
True if the text of <a> is greater than or equal to the text of <b> (disregarding case). Use NOT GE for less
|<a> EQ <b>
True if the text of <a> is identical to the text of <b> (disregarding case). Use NOT EQ for not equal.
||Specifies a numeric comparison.
||True if the file exists.
You can use local or global variables with IF by prefacing the variable name with a $ character.
IF $Language EQ "english"
IF $Language EQ "french"
IF $Language EQ "german"
The global variable Language is tested and an appropriate greeting is displayed for just 3 languages.
IF EXISTS Work/prog
TYPE Work/Prog HEX
ECHO "Work/Prog is not here"
AmigaDOS displays the file Work/Prog if it exists in the current directory, otherwise it displays the message and continues
after the ENDIF.
ECHO "No error"
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: ELSE, ENDIF, EXECUTE,
FAILAT, LAB, QUIT,
Return to Commands Selection
Disclaimer: Amiga Auckland have prepared the above information for the use of its members based on our experiences
and as such is subject to revision at any time. Amiga Auckland cannot guarantee any of the information and cannot be held
accountable for any issues that may result from using it.
Copyright © 2006 Amiga Auckland Inc. All rights reserved.
Revised: February 9, 2006.