MicroStation PowerDraft CONNECT Edition Help

if-then-else-endif文

デザインスクリプトのif-then-else-endif文は、要素に特定の属性があるかどうかを判別し、結果に応じてプログラムのフローを制御するために使用されます。構文の例を次に示します。

if (expression) then
  1 or more statements
endif

OR

if (expression) then
	 1 or more statements
else
	 1 or more statements
endif

OR

if(expression) then
	  1 or more statements
else if (expression) then
	  1 or more statements
else if ...
 else
	  1 or more statements
endif

if文の式の部分は整数を判定するものである必要があり、trueまたはfalseを返すのが一般的です。非ゼロ値はすべてtrueと判断されます。式がfalseまたはゼロと判定すると、文のelse部分(ある場合)が実行されます。次のデザインスクリプトセグメントは、if-then-else-endif構造を利用したものです。

例:

if (level == 23) then
	  style = (1, 0.5)
	  color = "green"
else if (level == 45) then
	  style = (1.0, 0.25, 0.5, 0.25) then
	  area_fill = true
	  color = "blue, sky"
else
 	 style = 0
	  color = (0, 0, 0)
endif