Numerical-choice

The numerical-choice is a somewhat baroque construct for choosing between a number of cases on the basis of an integer.

(315,160) (000,150)numerical-choice (000,130)(1,0)030040SELECT (1,0)030060expression (1,0)030040OF (1,0)005 (235,120)(20,20)[r] (235,110)(-1,0)210 (025,100)(20,20)[l] (025,090)(1,0)005040CASE (1,0)060070number (1,0)060010: (1,0)005 (105,080)(20,20)[rt] (125,080)(20,20)[lb] (125,070)(1,0)005070synonym-name (1,0)005 (205,080)(20,20)[rb] (225,080)(20,20)[lt] (235,080)(20,20)[rt] (245,080)(0,-1)020 (235,060)(20,20)[rb] (235,050)(-1,0)65 (095,050)(1,0)065010, (095,060)(20,20)[lb] (085,060)(0,1)020 (095,080)(20,20)[lt] (275,080)(20,20)[rt] (285,080)(0,-1)040 (275,040)(20,20)[rb] (275,030)(-1,0)005 (025,030)(1,0)185060paragraph (025,040)(20,20)[lb] (015,040)(0,1)040 (025,080)(20,20)[lt] (025,020)(20,20)[l] (205,020)(20,20)[l] (025,010)(1,0)005060OTHERWISE (1,0)030060paragraph (1,0)030060ENDSELECT (1,0)030

The cases must be labeled either with a number or with a synonym for a number, and therefore have a value fixed at compile-time. The labels of the cases must all be different and need not be ordered.

The numerical-choice is executed by first computing the value of the expression, which must yield an integer, and then executing the paragraph whose case label has that value, if any. If there is no paragraph labeled with this value, the otherwise-part (if any) is executed. The type of the numerical-choice is the type of the paragraph executed. Therefore all paragraphs in the numerical-choice must have the same type.