Home > Database > Mysql Tutorial > body text

有关QlikView循环的疑惑

WBOY
Release: 2016-06-07 15:54:23
Original
1106 people have browsed it

问题描述: 查阅了QlikView的help后知道QlikView的循环语法如下面Code所示: LET vTest1 = 1;LET vTest2 = 30;DO WHILE (vTest1 $(vTest2))LET vTest1 = $(vTest1) + 1;LOOP 可是令人不解的是为何把DO WHILE (vTest1 $(vTest2))替换成下面的方式后就变成死循

问题描述:

查阅了QlikView的help后知道QlikView的循环语法如下面Code所示:

LET vTest1 = 1;
LET vTest2 = 30;

DO WHILE (vTest1 < $(vTest2))

	LET vTest1 = $(vTest1) + 1;
LOOP
Copy after login
可是令人不解的是为何把DO WHILE (vTest1 < $(vTest2))替换成下面的方式后就变成死循环了:

DO WHILE ($(vTest1) < $(vTest2))。

Google了很多次,只是说在while条件只会被编译一次,而循环中的所有值都会在每一次循环中都被解析。

原文是这样的:Each condition is interpreted only the first time it is encountered but is evaluated for every time it encountered in the loop.

因此上面的条件就变成这样 DO WHILE (1 < 30)一直成立。

解决方法:
1. 在while条件里面不使用dollar sign,像这样DO WHILE (vTest1 < $(vTest2));

2. 在loop(循环)语句中使用EXIT DO WHEN如下:

LET vTest1 = 1;
LET vTest2 = 30;

DO WHILE ($(vTest1) < $(vTest2))

	LET vTest1 = $(vTest1) + 1;

	EXIT DO WHEN ($(vTest1) >= $(vTest2));

LOOP
Copy after login
疑问:
为何QklikView只会对条件编译一次?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!