Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Group: Flow Control
See also: case break default endsw

Function: switch
Description: switch allows the selection of one or more alternatives of many. Each alternative is introduced by a case statement. Similar to if-endif it controls, whether the following block is processed or not. The keyword break serves as end marker of case and leaves the switch block at the position of endsw. When break is omitted, the next consecutive case is processed. If the program's counter comes to default, the following block is executed in any case.


Usage: switch case (cond) break default endsw

Note:

Example:



proc (y) = sign (x)

  switch

    case (x<0)  y = -1  break

    case (x>0)  y =  1  break

    default     y =  0  break   ; this break has no effect

  endsw

endp



sign(-eh)

Result:



Contents of y

[1,]       -1 


Group: Flow Control
See also: case break default endsw

Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

(C) MD*TECH Method and Data Technologies, 21.9.2000