Simplicty and flexibility!


Support::

Case


Parameters


Returns/Result


Examples


Reference

case

image\Dql_0024.gifcase

Type

Procedural Command

Purpose

The case command functions like an if-then-else statement with multiple ifs. It tells DataEase to compare an expression to a series of values and execute a different action (or group of actions) based on which comparison is true.

When processing reaches a case command, DataEase compares the expression that follows the case command to each of the statements specified by the keyword value.

If the first comparison is true, DataEase executes all the actions between that value statement and the next value statement.

If the first comparison is not true, the case expression is compared to the next value statement. This comparing of values continues in top-to-bottom sequence from one value statement to the next until a true comparison is made.

If none of the specified value comparisons are true, DataEase executes the actions specified after the keyword others. If the others keyword is not present, DataEase executes none of the specified actions. It continues processing the remainder of the script.

As soon as the actions following any single statement are executed, processing passes to the first action following the end command for the case structure.

Syntax

case ( EXPRESSION)  

value COMPARISON 1 :

  ACTION SERIES 1 .

 [value COMPARISON 2 :

  ACTION SERIES 2 .]

 [value COMPARISON 3 :

  ACTION SERIES 3 .]

 [others :

  DEFAULT ACTION SERIES .]

end

 

Usage

The case command requires a case expression, at least one value statement, and an end command. Subsequent value statements, actions, and the others keyword are optional. If others is used, it must follow the last value statement.

The case expression must be enclosed in parentheses. It can be a field, a variable, or any other expression except a boolean expression (true or false). Each comparison value can be a constant, a variable, an expression, or a range of values.

An action can specify any valid procedure command including another if, while, or case command. Each nested command must be completed before processing passes to the first action after the end command (see the nested actions entry in this Lexicon).

When case commands are nested, the first end corresponds to the last preceding case, and each case command must be matched with a corresponding end command. This rule applies to all nested Procedural commands (including case, for, if, and while).

When you select case from the command pick list, DataEase automatically enters the opening ( (parenthesis).

Example

 value "FRANK" :

call menu "MAIN MENU" .

value "TOM" :

call menu "CLUB ADMINISTRATION" .

value "CAROL" :

run procedure "MAINTENANCE" .

others:

record entry "MEMBERS" .

end

 

This script tells DataEase: (1) If the current user is Frank, display the MAIN MENU document, (2) if the current user is Tom, display the CLUB ADMINISTRATION menu document, (3) if the current user is Carol, run the MAINTENANCE procedure, and (4) if the current user is anyone other than Frank, Tom, or Carol, display the MEMBERS form.

See Also


On the forum about Case

[@EOF@]...

Product: . Written by alembagheri tahmas 07/12/13 at 13:37:32

Hi there,I am trying to use an external MySQL DB in dataease. I have successfully create the ODBC link and added the DB to dataease. I can also access the DB from dataease. Now, just for testing purposes, I am trying to create a simple report b...

Product: DataEase for Windows 7.x. Written by George Washington 11/04/14 at 08:26:17

no se pude exportar ahora archivos a pdf, ni a excel o otros cosa mala. en verdad creo que hace faltaen las versiones anteriores me funcionaba mas o menos bien. le hace falta a los aplicativos que se desarrollan en Dataeasegr...

Product: DataEase 8 Reporter. Written by eduardo paez 02/05/14 at 14:40:11

Thanks. Anyway I'm trying to use this fuction but it seems to me that it doesn't work on 8.2. I tried also in a DQL.There's something wrong?<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9IAAAJ3CAYAAAB4NWk3AAAAAXNSR0IArs4...

Product: . Written by Marco Marchesi 15/02/16 at 14:50:46

[@EOF@]...

Product: Dataease [{8}]FIVE. Written by Chamil Rajindra 21/02/19 at 10:17:46

Thanks for the very good explanation!AS...

Product: . Written by afonso santos 28/10/19 at 00:50:14

I am pleased to see that the migration from Dos 4.53 is then sa 5.5 works. A really useful thing would be a compiler of SQL languages. Will you get there?Original Text:Mi compiaccio a vedere che la migrazione da Dos 4.53 è poi sa 5.5 funzio...

Product: . Written by Grossi Gioacchino 18/11/19 at 14:33:44

How can i delete a Style sheet?...

Product: Dataease [{8}]FIVE. Written by Rainer 22/03/21 at 11:13:10

I run W7 and since a few days&nbsp;Dataease 8.5 is not starting any more, do you have an idea? i installed it again but that did not help....

Product: Dataease [{8}]FIVE. Written by Rainer 08/06/21 at 14:12:40

[@EOF@]...

Product: . Written by Hiralal Rampul 01/12/21 at 17:47:10

On the blog about Case


dg3_HelpView