Switch: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Plugwash (talk | contribs)
No edit summary
 
Remove misleading information
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
The '''switch''' statement in con is similar to that in C.
The '''switch''' statement in CON is similar to that in C.


switch <gamevar>
  switch <gamevar>
  case <constant>
     case <constant>
    <do something>
      <do something>
     [[break]]
  case <constant>
    <do something>
     break
     break
endswitch
    case <constant>
      <do something>
    break
    default
      <do something>
    break
  endswitch
 
The '''case''' keyword works like an [[ifvare]] statement, and '''default''' operates on every possibility that is ''not'' specified by a case statement. Each case block must be terminated with a '''[[break]]''' statement.
 
See: [http://www.cplusplus.com/doc/tutorial/control/ Control Structures @ C++ Documentation]
 
[[Category:EDuke commands]]

Latest revision as of 23:16, 11 September 2021

The switch statement in CON is similar to that in C.

 switch <gamevar>
   case <constant>
     <do something>
   break
   case <constant>
     <do something>
   break
   default
     <do something>
   break
 endswitch

The case keyword works like an ifvare statement, and default operates on every possibility that is not specified by a case statement. Each case block must be terminated with a break statement.

See: Control Structures @ C++ Documentation