CASE
Starts a block of commands to execute if a variable has one of multiple values — or starts a multiple-choices decision structure itself
Implemented by: ansifull, bwbasic, bw32, QBasic, VBDOS, FreeBASIC, Gambas, EndBASIC
With variations:
Also written as:
Usage
Multiple CASEs are usually part of a SELECT-CASE branching structure. See the page for examples.
Variations
Modern versions of BBC BASIC replace the traditional SELECT-CASE structure with a SQL-like structure where the CASE keyword names the whole structure, such as the following example taken from //"An Introduction to Programming BBC BASIC"//:
CASE Choice% OF WHEN 1: PRINT "You chose option 1" WHEN 2: PRINT "You chose option 2" WHEN 3: PRINT "You chose option 3" ENDCASE
Examples
Comments
Related keywords
Similar keywords
In other languages...
Tcl, C and C-derived languages such as JavaScript and Java provide the equivalent switch-case structure.