(Case)

{ } (Case)

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

{ } (Case)

Selects one in a series of values.

Syntax

{ expression1 , expression2 }

Parameters

expression1any value expression
expression2any 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.

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_CAEnglish