EITHER

The EITHER function returns the result of the first argument that does not evaluate to "none".

Syntax:
EITHER (single-general-expression { , single-general-expression } )
Meaning:
EITHER ( try_this { , if_none_try_this } )
Returns:
A single object

The EITHER return methods work in the following ways:

Returns...
When...
try_this
try_this does not evaluate to "none"
if_none_try_this
try_this evaluates to "none"
the next if_none_try_this
the first if_none_try_this evaluates to "none"

Examples

  • EITHER ( OrderDate Field , CURRENTDATE ( ) )

    If OrderDate Field does not evaluate to "none", it is returned. If OrderDate Field evaluates to "none", the current system date (using CURRENTDATE) is returned.

  • EITHER ( LOOKUP (PriorityCd:Msg , CustID:Msg = "93X" ) , 8 )

    This example returns the result of the LOOKUP if that result does not evaluate to "none"; otherwise, it returns the second argument of 8.

  • EITHER (IF (SomeCode = "C" , CustomerID:Input) , IF (SomeCode = "S" , SupplierID:Input) , IF (SomeCode = "O" , Reference#:Input) , "####" )

    If SomeCode is C and CustomerID:Input has a value, EITHER returns the value of CustomerID. Otherwise, if SomeCode is S and CustomerID:Input has a value, EITHER returns the value of SupplierID. Otherwise, if SomeCode is O and Reference#:Input has a value, EITHER returns the value of Reference#. If none of those conditions result in a value, EITHER returns "####".

  • You can use EITHER when you want a default value when an expression evaluates to "none" and the expression might cause common arguments to produce an unintended result. For example, use:

    EITHER (LOOKUP (PriorityCd:Msg , CustID:Msg = "93X") , 8)

    -instead of-

    IF (PRESENT (LOOKUP (PriorityCd:Msg , CustID:Msg = "93X" ) ), LOOKUP ( PriorityCd:Msg , CustID:Msg = "93X" ) , 8 )