OSDN Git Service

SourceForge.JP で Mac 旧来の改行コード( CR のみ)の場合に正常に処理されないので、改行コードを変更。
[bacon/BaCon-Japanese.git] / 関数・命令 / SELECT.txt
1   SELECT
2
3    SELECT <variable> CASE <body>[;] [CASE <body>[;]][...] [DEFAULT <body>] END SELECT
4
5    Type: statement
6
7    With this statement a variable can be examined on multiple values.
8    Optionally, if none of the values match the SELECT statement may fall
9    back to the DEFAULT clause. Example:
10
11    SELECT myvar
12        CASE 1
13            PRINT "Value is 1"
14        CASE 5
15            PRINT "Value is 5"
16        CASE 2*3
17            PRINT "Value is ", 2*3
18        DEFAULT
19            PRINT "Value not found"
20    END SELECT
21
22    Contrary to most implementations, in BaCon the CASE keyword also may
23    refer to expressions and variables. Also BaCon knows how to 'fall
24    through' using a semicolon, in case multiple values lead to the same
25    result:
26
27    SELECT st$
28        CASE "Man"
29            PRINT "It's male"
30        CASE "Woman"
31            PRINT "It's female"
32        CASE "Child";
33        CASE "Animal"
34            PRINT "It's it"
35        DEFAULT
36            PRINT "Alien detected"
37    END SELECT
38