# When

when 前缀和后缀用于创建确定是否应执行语句或 exit 子句的条件子句。它可以被看作是完整的 if..end if 语句的简洁替代形式。

语法：

(when condition statement | exitstatement when condition )

仅当条件求值结果为 True 时，才会执行 statement 或 exitstatement。

when 前缀可以在已有一个或多个语句的语句上使用，包括其他 when 或 unless 前缀。

语法：

When 参数

| 参数 | 说明 |
| --- | --- |
| condition | 用于评估 True 或 False 的逻辑表达式。 |
| statement | 任意 QlikView 脚本语句，不包括控制语句。 |
| exitstatement | exit for、exit do 或 exit sub 子句或 exit script 语句。 |

示例：

`exit script 
 when A=1;` `when A=1 
 LOAD  * from myfile.csv;` `when 
 A=1 unless B=2 drop table Tab1;`