OSDN Git Service

GitHub で公開していた内容を SourceForge.JP へ複製
[bacon/BaCon-Japanese.git] / 関数・命令 / SELECT.txt
1   SELECT\r\r   SELECT <variable> CASE <body>[;] [CASE <body>[;]][...] [DEFAULT <body>] END SELECT\r\r   Type: statement\r\r   With this statement a variable can be examined on multiple values.\r   Optionally, if none of the values match the SELECT statement may fall\r   back to the DEFAULT clause. Example:\r\r   SELECT myvar\r       CASE 1\r           PRINT "Value is 1"\r       CASE 5\r           PRINT "Value is 5"\r       CASE 2*3\r           PRINT "Value is ", 2*3\r       DEFAULT\r           PRINT "Value not found"\r   END SELECT\r\r   Contrary to most implementations, in BaCon the CASE keyword also may\r   refer to expressions and variables. Also BaCon knows how to 'fall\r   through' using a semicolon, in case multiple values lead to the same\r   result:\r\r   SELECT st$\r       CASE "Man"\r           PRINT "It's male"\r       CASE "Woman"\r           PRINT "It's female"\r       CASE "Child";\r       CASE "Animal"\r           PRINT "It's it"\r       DEFAULT\r           PRINT "Alien detected"\r   END SELECT\r\r