Difference between revisions of "Command:Switch"

From Lavish Software Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Syntax ==
+
#REDIRECT [[Control:Switch]]
{{CMD-DR|Switch|Intermediate|Intermediate|Beginner|Intermediate}}
 
Switch <text>
 
 
 
== Description ==
 
Executes one of many conditional branches, depending on the value of the switch.  Cases are checked for equality (case insensitive).  The first case to match exactly will be executed.  If no explicitly defined cases match, the Default, if any, will be executed.  [[Command:EndSwitch|EndSwitch]] must be used to end the switch.
 
 
 
== Examples ==
 
Switch ${Fruit.Color}
 
{
 
  case Red
 
    echo Is the fruit a strawberry?
 
    break
 
  case Blue
 
    echo Is the fruit a blueberry?
 
    break
 
  case Yellow
 
    echo Is the fruit a banana?
 
    break
 
  Default
 
    echo I don't know what kind of fruit might be ${Fruit.Color}!
 
    break
 
}
 
EndSwitch
 
 
 
== See Also ==
 
*[[LavishScript:Control Structures]]
 
*[[Command:Break|Break]]
 
*[[Command:Case|Case]]
 
*[[Command:Default|Default]]
 
*[[Command:EndSwitch|EndSwitch]]
 
*[[LavishScript:Commands|Commands]]
 
{{Command-Stub}}
 

Latest revision as of 02:38, 13 September 2005

Redirect to: