Type in a command, or "ls dictionary" to search all commands for "dictionary", etc.

ifthen

(This command has been awarded a Yubnub Golden Egg)

http://jonathanaquino.com/yubscripts/ifthen/ifthen.php?value1=${value1}&value2=${value2}&test=${test}&then=${then}&els=${else}&redirect=${redirect=false}&input=%s&delimit=${delimit=,}&xn_auth=no
NAME
    ifThen - Compares two values (or evaluates a conditional statement) and returns a value based on the result

SYNOPSIS
    This command can be used with two different syntaxes:
    ifThen -value1 [VALUE 1] -value2 [VALUE 2] -test [CONDITIONAL TEST] -then [RESULT IF TRUE] -else [RESULT IF FALSE] -redirect [REDIRECT]
    OR:
    ifThen (CONDITIONAL STATEMENT)RESULT IF TRUE, RESULT IF FALSE -delimit [DELIMITER] -redirect [REDIRECT]


EXAMPLES
    The following are examples using both of the two syntaxes:

    ifThen -value1 16 -value2 23 -test LESS -then yub -else nub
    ifThen (16<23)yub,nub
        (Returns "yub" because 16 is less than 23)

    ifThen -value1 abcdefg -value2 abcdefg -test NOTEQUAL  -then yub -else nub
    ifThen (abcdefg<>abcdefg) yub, nub
        (This would return "nub" because the two values are equal, thus failing the test)

    ifThen -value1 100 -value2 100 -test LESSEQUAL  -then http://www.google.com -redirect true
    ifThen (100<=100)http://www.google.com -redirect true
        (Redirects to the the Google website.)

    ifThen -value1 100 -value2 100 -test LESSEQUAL  -then http://www.google.com -redirect false
    ifThen (100<=100)http://www.google.com -redirect false
        (Returns the Google URL as a string.)
        
        
    The second syntax will also evaluate as true if the value in parentheses is TRUE, 1, or YES:
    
    ifThen (True)yub, nub
        (Returns "yub")

DESCRIPTION
    Compares two values or evaluates a conditional statement and returns a result depending on the result.

    '-VALUE1' and '-VALUE2' are compared using the method defined by the '-TEST' parameter ,or
    the conditional statement is evaluated, if the result is true then the RESULT IF TRUE is returned.
    Otherwise the RESULT IF FALSE is returned (or nothing is returned if undefined).
    
-ELSE, RESULT IF FALSE, -REDIRECT and -DELIMIT are optional parameters

    Possible values for the '-test' parameter in the first syntax are:
        GREATER       - returns true if value1 is greater than value2
        LESS          - returns true if value1 is less than value2
        GREATEREQUAL  - returns true if value1 is greater than or equal to value2
        LESSEQUAL     - returns true if value1 is less than or equal to value2
        EQUAL         - returns true if value1 is equal to value2
        NOTEQUAL      - returns true if value1 is not equal to value2
        
    Possible conditional operators for the second syntax are:
         >      - greater than
         <      - less than
         >=     - greater than or equal
         <=     - less than or equal
         ==     - equal to
         <>     - not equal to

    The '-redirect' parameter can be set to True or False. It defaults to False. If set to True and
    the result of the command begins with "HTTP" then the the command will attempt to
    redirect the user to the web site.
    
    The '-delimit' parameter can be used to change the value that separates RESULT IF TRUE and
    RESULT IF FALSE. It defaults to a comma (,). This is only used for the second syntax.
    
NOTES
    This implementation of ifThen combines the original ifThen syntax with the new syntax first used
    in the 'ift' command.

AUTHOR
    Allen Ormond <aormond (at) gmail (dot) com>
    
1090467 uses - Created 2005-08-12 04:14:04 - Last used 2023-11-19 06:52:35
Is this command broken? Tell Jon if you know how to fix it.