Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - case label for multiple conditional branch http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 case                Label for multiple conditional branch
------------------------------------------------------------------------------
 Syntax
   do case
   [ case <condition> ]
      [ <code> ]
   [ otherwise ]
      [ <code> ]
   endcase

 Arguments
   <condition> is an expression that evaluates to a logical value.
   <code> is a block of executable code.

 Description
   The case statement delimits a conditional block within a do case
   structure. Execution of code belonging to a particular case block happens
   if the condition associated with that block evaluates to true.

   A do case structure contains none to several case blocks whose code forms
   the body of the construct. The conditional expressions of the case blocks
   are evaluated consecutively, until one of them evaluates to true, and the
   execution of its code begins. After executing the code block, control
   drops out to the first code line following the endcase statement of the
   case construct.

 Example
   #define EXAMPLE_STATEMEN
   #include example.hdr

   proc DispMsg static
   param value uint uRow, value uint uCol, const char cText
   @ uRow, uCol ?? cText
   endproc
   
   proc Test_case
   vardef
      _SLIST pList
      uint   n
      uint   uChoice
   enddef
   pList := pickinit()
   for n := 0 to 6
      pickadd( pList, __daynames[ n ] )
   next
   clear
   uChoice := pickdisp( pList, 8, 35, 14, 45 )
   do case
   case uChoice == 0
      @ 20, 0 ?? "You seemingly pressed Escape"
   case uChoice == 1
      @ 20, 0 ?? "You selected", pickstr( pList, uChoice )
   case uChoice == 2
      @ 20, 0 ?? "The", istr( uChoice ) + "nd day of week is", ;
         __daynames[ uChoice - 1 ]
   case uChoice == 3
      DispMsg( 20, 0, "Let's call a function" )
   otherwise
      @ 20, 0 ?? "The docs writer became tired at this point"
   endcase
   pickclear( pList )
   endproc

   proc main
   Test_case()
   endproc

See Also: do case otherwise

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson