switch
Username:  
Password:
  > Home
> User Guide
v Reference
    > Introduction
    > CROFT
    > BEE Variables
    > BEE Syntax
    v BEE Commands
       > Variable Operations
       v Conditional
          o if
          o else
          o elseif
          o switch
          o case
          o hide
          o show
       > Loop
       > Module Calling
       > Remote Calling
       > Authentication
       > Data Access
       > Socket
       > Special Functions
    > Database Operation
    > Content Management
    > Objects and Classes
    > Interface with others
    o Glossary
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> Reference >> BEE Commands >> Conditional >> switch <=  =>      <  1  >  
switch – conditional execution of blocks based value matching

BEE Script:   switch (value)

            {

            case value:

                  statement;

                  ...

                  [break;]

            [case value:

                  statement;

                  ...

                  [break;]]

            ...

            [default:

                  statement;

                  ...

                  [break;]]

            }

 

BEE Tag:     <beeswitch "value">

            <beecase "value">

                  tag

                  ...

                  [<beebreak>]

            [<beecase "value">

                  tag

                  ...

                  [<beebreak>]]

            ...

            [<beecase>

                  tag

                  ...

                  [<beebreak>]]

            </beeswitch>

 

Note 1: In BEE Tag form, "case" without a value is the "default" case.  (In BEE Script form, the alias "default" will be translated to a "case" command with no parameter.)

Note 2: All contents (scripts, HTML codes or text), if any, between "switch" and the first "case" will be ignored.

The "switch" command specify a value for matching with the one in the "case" command.  If one is matched, the block specifies after the "case" command will be executed until a "break" command is encountered, then exist the "switch" block.

If there is no "break" statement in the block of matching "case" value, the execution will fall through to the next block until a "break" command is executed.  So it is possible that multiple blocks are executed before the exist of the "switch" block.

If none of the "case" command got a value matching the one in the "switch" command, the "default" block if exists will be executed.  If the "default" block is not specified, the whole "switch" block will be skipped with no execution at all.

Example:

display "Please wear ";

switch ("{patron}")

{

case "woman":

case "girl":

      display "skirt";

      break;

case "man":

      display "tie and ";

      // Fall through

case "boy":

      display "shirt";

      break;

default:

      display "properly";

}

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd