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

\textbf{{\char36}FCHOOSE}\textbf{(}\icamhsp{0.707mm}\mathit{index}\;\icamrange{0.66}{1}\,\bigl(,\mathit{value_{n}}\,\bigr)\icamhsp{0.707mm}\textbf{)}

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

\textbf{{\char36}FIF}\textbf{(}\icamhsp{0.707mm}\mathit{expr},\mathit{truearg},\mathit{falsearg}\icamhsp{0.707mm}\textbf{)}

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

\textbf{{\char36}FISNUM}\textbf{(}\icamhsp{0.707mm}\mathit{a}\icamhsp{0.707mm}\textbf{)}

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

\textbf{{\char36}FISSEQ}\textbf{(}\icamhsp{0.707mm}\mathit{a}\icamhsp{0.707mm}\textbf{)}

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

\textbf{{\char36}FISSTR}\textbf{(}\icamhsp{0.707mm}\mathit{a}\icamhsp{0.707mm}\textbf{)}

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

\textbf{{\char36}FISWRD}\textbf{(}\icamhsp{0.707mm}\mathit{a}\icamhsp{0.707mm}\textbf{)}

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

\textbf{{\char36}FSWITCH}\textbf{(}\icamhsp{0.707mm}\;\icamrange{0.66}{1}\,\bigl(\,\mathit{expr_{n}},\mathit{value_{n}}\,\bigr)\icamhsp{0.707mm}\textbf{)}

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.