If-Then-Else-Endif 语句
设计脚本中使用 If-then-else-endif 语句确定元素是否包含某些特性并基于结果控制程序流。下面为示例语法:
if (expression) then 1 or more statements endif
或
if (expression) then 1 or more statements else 1 or more statements endif
或
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