Difference between revisions of "Shell Commands/If"

From MorphOS Library

< Shell Commands

(Created page with "'''If''' - Adds intelligent branching to scripts NOT/S, WARN/S, ERROR/S, FAIL/S, EQ/K, GT/K, GE/K, VAL/S, EXISTS/K, NOREQ/S...")
 
 
Line 10: Line 10:
 
FAIL  - True if previous return code is greater than or equal to 20;
 
FAIL  - True if previous return code is greater than or equal to 20;
 
         only available if FailAt is set to greater than 20.
 
         only available if FailAt is set to greater than 20.
EQ    - a EQ b: true if the text of a is greater than the text of b
+
EQ    - a EQ b: true if the text of a is equal to the text of b
 
         (disregarding case).
 
         (disregarding case).
        use NOT GT for less than.
+
GT    - a GT b: true if the text of a is greater than the text of b
GT    - a GT b: true if the text of a is greater than
+
        (disregarding case).
        or equal to the text of b (disregarding case).
+
         Use NOT GT for less than.
         use NOT GE for less than or equal to.
 
 
GE    - a GE b: true if the text of a is greater than or equal to
 
GE    - a GE b: true if the text of a is greater than or equal to
 
         the text of b (disregarding case).
 
         the text of b (disregarding case).
         use NOT GE for less than or equal to.
+
         Use NOT GE for less than or equal to.
 
VAL    - a VAL b: true if the text of a and b is identical (disregarding case).
 
VAL    - a VAL b: true if the text of a and b is identical (disregarding case).
 
EXISTS - true if the specified file or directory exists.
 
EXISTS - true if the specified file or directory exists.

Latest revision as of 13:49, 6 March 2015

If - Adds intelligent branching to scripts

NOT/S, WARN/S, ERROR/S, FAIL/S, EQ/K, GT/K, GE/K, VAL/S, EXISTS/K, NOREQ/S

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.
EQ     - a EQ b: true if the text of a is equal to the text of b
         (disregarding case).
GT     - a GT b: true if the text of a is greater than the text of b
         (disregarding case).
         Use NOT GT for less than.
GE     - 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 than or equal to.
VAL    - a VAL b: true if the text of a and b is identical (disregarding case).
EXISTS - true if the specified file or directory exists.
NOREQ  - suppresses error requesters

NOTES: 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:

If EXISTS Work/Prog
    Type Work/Prog HEX
Else
    Echo "It's not here"
EndIf