Conditional Functions
Conditional functions return the $TRUE or $FALSE status of a conditional test, or the value of a function argument based on or associated with an expression.
The $FCHOOSE Function
Selects and returns a value from a list of arguments Returns: Any or $NULL |
The $FCHOOSE function returns the nth value from a list of choices based on the index value. If index is 1, $FCHOOSE returns value 1 (i.e., the first choice in the list). If index is 2, it returns value 2 and so on.
The index value is rounded to the nearest whole number before being evaluated. The $FCHOOSE function returns a value of $NULL if index is less than 1 or greater than the number of values listed.
$FCHOOSE evaluates all of the value expressions, even though it returns only one of them. For this reason, you must watch for undesirable side effects. For example, if the evaluation of any of the value expressions results in a division by zero error, an error occurs regardless of the value of index.
The $FIF Function
Returns one of two arguments, depending on a logical expression Returns: Any |
The $FIF function evaluates the logical expression expr and returns the argument truearg if the logical expression is true, or the argument falsearg if the logical expression is false.
$FIF always evaluates both truearg and falsearg, even though it returns only one of them. Because of this, you must watch for undesirable side effects. For example, if evaluating falsearg results in a division by zero error, an error occurs even if expr is true.
The $FISNUM Function
Test if numeric Returns: Logical |
The $FISNUM function returns $TRUE if the argument a is a number. $FALSE is returned if the argument is any other type, including $NULL.
The $FISSEQ Function
Test if sequence Returns: Logical |
The $FISSEQ function returns $TRUE if the argument a is a sequence. $FALSE is returned if the argument is any other type, including $NULL.
The $FISSTR Function
Test if string Returns: Logical |
The $FISSTR function returns $TRUE if the argument a is a string or character. $FALSE is returned if the argument is any other type, including $NULL.
The $FISWRD Function
Test if keyword (minor) Returns: Logical |
The $FISWRD function returns $TRUE if the argument a is a MINOR word. $FALSE is returned if the argument is any other type, including $NULL.
The $FSWITCH Function
Returns argument associated with first true logical expression Returns: Any or $NULL |
The $FSWITCH function’s argument list consists of pairs of logical expressions and values. The logical expressions expr are evaluated from left to right. The value associated with the first expression that evaluates true is returned. For example, if expr1 is true, $FSWITCH returns value1. If expr1 is false, but expr2 is true, $FSWITCH returns value2 and so on.
$FSWITCH returns a value of $NULL if none of the expressions are true. To return some other value if all expressions are false, use .TRUE. or $TRUE as a final expression paired with the required value. For example:
$FSWITCH( … ,.TRUE.,value)$FSWITCH evaluates all of the expr and value expressions, even though it returns only one value. For this reason, you must watch for undesirable side effects. For example, if the evaluation of any expr or value expression results in a division by zero error, an error occurs regardless of the expr true/
false conditions.