Recent Changes - Search:
Email iofreak@yahoo.com with comments and/or suggestions.

Aibo General

Aibo Development

Wiki Help

Aibo Links

R-Code » SWITCH

SWITCH ... CASE Statement

Multiple-branching conditional execution. The SWITCH statement sets the current value of the Context, each CASE statement with a value matching the context is executed.

Models

ERS-210 ERS-220 ERS-31x ERS-7

Syntax

SWITCH:variable
[CASE:const:command]
[...]
[CASE:ELSE:command]
[...]

The SWITCH...CASE statement syntax has the following parts:

PartDescription
variableVariable or constant, sets the Context.
constConstant value. Compared against the Context value.
commandAny R-CODE statement (excluding CASE).

Example(s)


   SWITCH:x
   CASE:1:PRINT:"x = 1"
   CASE:2:PRINT:"x = 2"
   CASE:2:PRINT:"(two)"
   CASE:3:PRINT:"x = 3"
   CASE:ELSE:PRINT:"x is not 1"
   CASE:ELSE:PRINT:"x is not 2"
   CASE:ELSE:PRINT:"x is not 3"
 

Remarks

Add CASE:ELSE at the end of a series of CASE statements, when the Context value is not equal to any of the CASE constants, commands associated with the ELSE statement are executed.

Edit - History - Print - Recent Changes - Search - Site Terms of Use
Page last modified on July 25, 2006, at 08:37 PM CST