制御文
スクリプトではif文を使うことができます。
if文は以下の形式で記述します。
- if 条件 then ブロック endif
- if 条件 then ブロック1 else ブロック2 endif
- if 条件1 then ブロック1 elseif 条件2 then ブロック2 elseif ... else ブロックn endif
例:
---------------------------
function funcX(x)
local y
if x < 10 then
y = 10
elseif x < 20 then
y = 20
elseif x < 30 then
y = 30
else
y = 40
end
return y;
end
---------------------------
参照: 数式とは/ その他の演算子/ スクリプトとは
キーワード: 制御文/if/if文
|