{ } (Case)

Selects one in a series of values.

Syntax

{expression1«,expression2»}

Parameters

expression1

any value expression

expression2

any value expression

Return Value

The value of the first of the expressions that is not $Null.

Comments

The expressions within the braces are evaluated from left to right. The case expression takes the value of the first expression that is not $Null. The expressions can themselves be written in case format.

Case expressions provide a useful way of dealing with values that are conditional, depending on another value. Each "case" within the braces is evaluated from left to right until one case yields a value that is not $Null. The case expression returns this value.

Case expressions can minimize the code that is required to produce certain conditional results. For example

let Status = {'tall' where Height > 6, 'short'}

replaces

if Height > 6
  let Status = 'tall'
else
  let Status = 'short'
endif

Case expressions can ensure that a value is provided in situations where a field or widget alone can sometimes be $Null. For example:

let Salary = {fAddEmps.Salary, 0}

Case expressions can also be used to determine the action to be taken by certain commands as shown in the following example:

break 1 \
  {$year(InvDate) + 1 where $month(InvDate) >= 5, \
  $year(InvDate)} \
  heading ...

Example

detail line "Employee Number: " {EmpNum, "N/A"}

The preceding command prints, in a report, the string N/A where employee numbers are missing.