<< return Control flow then >>

Scilab Help >> 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

有効な命令のブロック.

説明

注意:

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

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

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

参照

履歴

VersionDescription
6.0.0 select is now protected: Assignments like select=1 are no longer possible.

Report an issue
<< return Control flow then >>