Available on: all targets

SELECT CASE...CASE...CASE ELSE...ENDSELECT

These commands implement a multiple conditional jump. It is a question of verifying whether a given expression, supplied as first, is equal to the various expressions that will be gradually registered through the CASE statement. If they are, the code following the CASE statement will be executed. Otherwise, we will move on.

If the CASE ELSE statement is given, it will be executed if there is no other match. It follows that it must be placed last.

The code executed is always and only the one between the CASE that satisfies the condition and the next one (or the CASE ELSE). The code on CASE ELSE will be execute always and only if other matches fail.

SYNTAX

 SELECT CASE [expression] : CASE [match1] : ... {: CASE [match2] : ... } { : CASE ELSE : .... } : ENDSELECT


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 SELECT CASE number
   CASE 1
      PRINT "one!"
   CASE 2
      PRINT "two!"
   CASE ELSE
      PRINT "neither!"
 ENDSELCT


Used in:

ABBREVIATION: SlCs...Cs...CsEl...Es

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

SELECT CASE...CASE...CASE ELSE...ENDSELECT ↔ SlCs...Cs...CsEl...Es

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS