====== SELECT CASE ====== /* Remove the comments after creating content for each section.*/ A conditional branching structure to allow definition of multiple different actions to be taken according to the value of an expression or variable /* For the lines below, just create links, separated by commas, to other pages of the BASICs section, like [[:basics:basicTagName]]. "Implemented by" should mention BASICs which implement the keyword like described, in a more usual and standard way. "With variations" should point to BASICs where this keyword is used a bit differently. "Also written as" should list alternative spellings and abbreviations this keyword has. No need to refer to a BASIC, there is a section for that later. */ **Implemented by:** [[:basics:Dartmouth:sbasic]], [[:basics:ANSI:ansifull]], [[:basics:bwbasic:]], [[:basics:bwbasic:bw32]], [[:basics:msqb:QBasic]], [[:basics:VBDOS:]], [[:basics:FreeBASIC:]], [[:basics:ugBASIC:]], [[:basics:EndBASIC:]] **With variations:** [[:basics:Gambas:]] **Also written as: ** ===== Usage ===== /* For inline examples of syntax, write the keyword between '' and '' (two single quotes) */ SELECT-CASE is not by itself a BASIC keyword, but the most popular name of a multibranch structure which substitutes a possibly long sequence of [[IF]]s and [[ELSE]]s. SELECT-CASE is more often found in structured, not numbered-line versions of BASIC, but it might be found in line-numbered BASICs as well. The [[:basics:ansi:ansifull|ANSI Full]] specification has some examples, such as: 10 SELECT CASE X 20 CASE IS < 0 30 PRINT X; "is negative" 40 CASE IS > 0 50 PRINT X; "is positive" 60 CASE ELSE 70 PRINT X; "is zero" 80 END SELECT ==== Variations ==== ===== Examples ===== /* Below is an example of a code block, using GeSHi syntax highlighting for //gwbasic//. Other styles of interest might be //basic4gl//, //blitzbasic//, //freebasic//, //gambas//, //locobasic//, //purebasic//, //qbasic//, //sdlbasic//, //thinbasic//, //vb//, //vbnet//, //xbasic// or //zxbasic//. 10 PRINT "HELLO" */ ===== Comments ===== /* Origin of the keyword, opinions, history... */ ===== Related keywords ===== /* Keywords that are often or always used along this one */ * [[CASE]] * [[ELSE]] * [[ENDSELECT]], [[END SELECT]] and [[ENDCASE]] ===== Similar keywords ===== /* Keywords with the same or similar functionality found in other versions of BASIC */ * [[CASE]] * [[IF]], [[ELSE]], [[ELSEIF]] ===== In other languages... ===== /* For parallels and comparisons with other modern-day languages */ The SELECT-CASE structure is very similar to the //switch...case// structure found in C and descendents such as PHP, Java, Javascript. Tcl also has a //switch// command which dispenses the //case// keyword and basically works with string comparison only. Python had to wait until version 3.10.6 to have a similar structure, //match...case//. ===== References ===== /* If you used the ((citation)) syntax elsewhere in the text, they will appear under this section. But you can write some recommendations of books, magazines, etc */ /* ===== TAGS ===== Please use the syntax below for adding tags to this page, separated by spaces (use quotes for tags with spaces). The most important tags to be used are, separated by groups: - Statements | Commands | SpecialVariables | Operators {{tag>tagName}} */ {{tag>Statements Branching Decision "Program Flow" Structured}}