Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.0 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Scilab > Control flow > select

select

select キーワード

呼び出し手順

select variable
case value1 then
instructions 1
case value2 then
instructions 2
...
case valuen then
instructions n
[else instructions]
end

引数

variable

値を解析する変数.

value1, ..., valuen

適当な命令ブロック instructions 1, ..., instructions n が存在する variableの値.

instructions

有効な命令のブロック.

説明

注意:

  • 唯一の規則は,各thenキーワードを対応する caseキーワードと同じ行に置く必要があることです (または,連続化記号を使用します, ドット参照).

  • キーワード "then"の代わりにキャレッジリターン またはカンマを使用することができます. instructions1expr1=expr の場合に実行される, といったようになります.

Scilabプログラミング言語のコード規約に基づき, 以下が推奨されます:

  • 各命令を新しい行で開始する.

  • 1行に複数の命令を記述しない.

  • 複合命令は,複数行に分割する.

例えば, 以下のようにします:

A = 2
select A
case 1 then
    disp(1)
case 2 then
    disp(2)
else
    disp(3)
end

以下は推奨されません.

A = 2;select A case 1 then disp(1); case 2 then disp(2); else  disp(3); end

警告: 条件文(if while for または select/case)の本体の定義に使用できる 文字数は 16k に制限されています.

while %t do
  n=round(10*rand(1,1))
  select n
  case 0 then
    disp(0)
  case 1 then
    disp(1)
  else
    break
  end
end

参照

  • if — 条件付き実行
  • while — while キーワード
  • for — ループ用の言語キーワード
Report an issue
<< return Control flow then >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 14 15:10:24 CET 2017