PC SOFT

WINDEV的在线文档

  • Code to run
  • Exiting from a WHILE loop
  • Loop without end
  • Running the next iteration
  • Composite condition
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

In a 只要 statement, the expression is evaluated at each beginning of the statement block.

The process loops as long as the condition expression is True. The program will exit from the statement block when the condition is False.

18版本和更高版本
WinDevWindows Store apps This feature is available in Windows Store apps mode.
18新版本
WinDevWindows Store apps This feature is available in Windows Store apps mode.
WinDevWindows Store apps This feature is available in Windows Store apps mode.
例子
MyListINI文件读"Examples"""""INIFile
Keyword提取字符串MyListnb回车
只要Keyword不等于""
nbnb+1
ExplNameINI文件读"Projects installed"Keyword""INIFile
Keyword提取字符串MyListnb+1回车
结束

语法

"WHILE" condition 隐藏详细信息

 只要 <Condition>
  <Action if condition is True>
END

<WHILE>:
Marks the beginning of the statement block.
<Condition>:
Condition to check.
<Action if condition is True>:
Action to perform if the condition is True.
<END>:
Marks the end of the statement block.

Loop with exit according to a "WHILE" condition 隐藏详细信息

 循环
  ...
  DO WHILE <Condition>

<LOOP>:
Marks the beginning of the statement block.
<DO WHILE>:
Marks the end of the statement block. Used to exit from the statement block. The lines of the loop found before this statement are run.

注意

Code to run

The code to run is located between the WHILE and 结束 statements.

Exiting from a WHILE loop

Several statements are available:
  • 返回 statement: Exits from the 只要 loop and exits from the current process (or procedure).
  • 返回 statement: Return a status report to the calling process. Exits from the 只要 loop and exits from the current process (or procedure).
  • 跳出 statement/"跳出:" label: Exits from the 只要 loop and runs the rest of the current process.
关闭 is used to exit from the 只要 loop and to close the current window.

Caution: 返回 statement and 返回 statement cannot be used in the same process.

Loop without end

During the compilation of the project, a 只要 loop without an obvious end (loop without 跳出 statement/"跳出:" label, 返回 statement or 返回 statement statement) is signaled by a warning.

Running the next iteration

To directly run the next iteration without ending the code of the next iteration, use the 继续 statement / "继续:" label statement:
WHILE <Condition>
...
IF <Condition> THEN CONTINUE  // Go back to the WHILE keyword
...
END

Composite condition

The 并且 and 或者 keywords are used to perform logical operations and to create composite conditions.

For example:

只要Price小于100并且ProductType"AA"
NumProduct++// Number of products whose price is less than
// 100 and whose type is "AA"
结束

只要Price大于100或者Price小于500
NumProduct++// Number of products whose price is included between €100 and €500
结束

The conditions made of 并且 and 或者 are entirely evaluated.

For example:

A1大于10并且B1小于20
Even if the first condition (A1 > 10) is false, the second condition (B1 < 20) will be checked.

Optimizing the evaluation of composite conditions: Use the 最优并且 and 最优或者 keywords. If the first condition is false (A1 > 10 in our example), the second condition (B1 < 20 in our example) will not be checked.