Difference between revisions of "DO CASE"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Multiple choice selection command
 
Multiple choice selection command
 
  
 
==Syntax==
 
==Syntax==
Line 19: Line 18:
  
 
ENDCASE
 
ENDCASE
 
  
 
==See Also==
 
==See Also==
[[@...MENU]], [[DO WHILE]], [[ICASE()]], [[IF]], [[IF()]], [[IIF()]]
+
[[DO WHILE]], [[ICASE()]], [[IF]], [[IF()]], [[IIF()]]
 
+
  
 
==Description==
 
==Description==
The DO CASE command selects one course of action out of many alternatives.  Recital evaluates each CASE <condition> in turn.  As soon as one of the conditions evaluates to true (.T.) the <commands> for that CASE are executed and any further case statements are ignored.  Following execution of the <commands>, the program continues after the ENDCASE statement.
+
The DO CASE command selects one course of action out of many alternatives.  Lianja evaluates each CASE <condition> in turn.  As soon as one of the conditions evaluates to true (.T.) the <commands> for that CASE are executed and any further case statements are ignored.  Following execution of the <commands>, the program continues after the ENDCASE statement.
  
 
====OTHERWISE====
 
====OTHERWISE====
Line 34: Line 31:
 
If no CASE <condition> is .T., and there is no OTHERWISE statement specified, then control skips to the next command following the ENDCASE.
 
If no CASE <condition> is .T., and there is no OTHERWISE statement specified, then control skips to the next command following the ENDCASE.
  
CASE statements, as with all of the other Recital statements can be nested.  In other words, a CASE statement can contain further DO CASE commands.
+
CASE statements, as with all of the other Lianja statements can be nested.  In other words, a CASE statement can contain further DO CASE commands.
 
+
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
accept "Enter a command: " to command
 
 
do case
 
do case
     case command = "BROWSE"
+
     case mColor = "red"
         browse
+
         // do something
     case command = "DIR"
+
     case mColor = "blue"
         dir
+
         // do something else
 
     otherwise
 
     otherwise
         set message to "Unknown command."
+
         // any other mColor value
 
endcase
 
endcase
 
</code>
 
</code>
  
 
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
[[Category:Applications]]
 
[[Category:Applications Commands]]
 
 
[[Category:Looping Commands]]
 
[[Category:Looping Commands]]

Latest revision as of 10:57, 4 February 2013

Purpose

Multiple choice selection command

Syntax

DO CASE

CASE <condition>

[<commands>]

[CASE <condition>

[<commands>]]

[OTHERWISE

[<commands>]]

ENDCASE

See Also

DO WHILE, ICASE(), IF, IF(), IIF()

Description

The DO CASE command selects one course of action out of many alternatives. Lianja evaluates each CASE <condition> in turn. As soon as one of the conditions evaluates to true (.T.) the <commands> for that CASE are executed and any further case statements are ignored. Following execution of the <commands>, the program continues after the ENDCASE statement.

OTHERWISE

If an OTHERWISE statement is present and no CASE <condition> evaluates to .T., the OTHERWISE <commands> are executed.

ENDCASE

If no CASE <condition> is .T., and there is no OTHERWISE statement specified, then control skips to the next command following the ENDCASE.

CASE statements, as with all of the other Lianja statements can be nested. In other words, a CASE statement can contain further DO CASE commands.

Example

do case
    case mColor = "red"
        // do something
    case mColor = "blue"
        // do something else
    otherwise
        // any other mColor value
endcase