PC SOFT

WINDEV的在线文档

  • Other statements used to exit from a loop
  • Use example for the "BREAK:" label
  • "BREAK:" statement: Case of nested loops
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系: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本地访问

跳出 is used to exit from a statement block and to run the rest of the current process.

跳出 can be used in the following types of loops:

Note: The BREAK statement cannot be used to exit from a procedure. Use the RETURN and RESULT keywords.

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.

The keyword 跳出 can correspond:

  • to the 跳出 statement:
跳出 is used to exit from a statement block and to run the rest of the current process. 跳出 can be used in the following types of loops:Note: The BREAK statement cannot be used to exit from a procedure. Use the RETURN and RESULT keywords.

  • 19版本和更高版本
    to the BREAK: statement:
    The "BREAK:" label is used to declare a code in a loop.
    • This code will be run when exitingfrom the loop with a "BREAK" statement.
    • This code will never be run for each iteration of the loop.
    19新版本
    to the BREAK: statement:
    The "BREAK:" label is used to declare a code in a loop.
    • This code will be run when exitingfrom the loop with a "BREAK" statement.
    • This code will never be run for each iteration of the loop.
    to the BREAK: statement:
    The "BREAK:" label is used to declare a code in a loop.
    • This code will be run when exitingfrom the loop with a "BREAK" statement.
    • This code will never be run for each iteration of the loop.

语法

BREAK statement used in a FOR statement

 对于 <Control Variable> = <Initial Value> TO <Final Value> [STEP <x>]
  ...
  IF <Condition> THEN BREAK
  ...
END
<Rest of process>

BREAK statement used in a FOR EACH statement

 对于 EACH <File> ON <Key Item>
  ...
  IF <Condition> THEN BREAK
  ...
END
<Rest of process>

BREAK statement used in a LOOP statement

 循环
  ...
  IF <Condition> THEN BREAK
  ...
END
<Rest of process>

BREAK statement used in a WHILE statement

 只要 <Condition>
  ...
  IF <Condition> THEN BREAK
  ...
END
<Rest of process>
 The following operations are performed if <Condition> is True:
- Exit from the statement block.
- Run the rest of the current process.

注意

Other statements used to exit from a loop

Several statements are available:
  • 返回 statement: Exit from the loop and exit from the current process (or procedure).
  • 返回 statement: Return a status report to the calling process. Exit from the loop and exit from the current process (or procedure).
关闭 is used to exit from the loop and to close the current window.

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

19版本和更高版本

Use example for the "BREAK:" label

In this example, the total representing the sum of the last 10 invoices is displayed.

NbInvoices整数型
TotInv货币型

NbInvoices0
H读最后一个InvoiceInvNum
只要不H超出()
NbInvoice++
如果NbInvoices大于等于10,那么跳出// Jump directly to the BREAK: label
// Adds the invoices
TotInv+=Invoice.Amount

跳出:
// Exits from the loop after 10 iterations
信息"The total for the last 10 invoices is: "InvTtl
H读上一个InvoiceInvNum
结束
19新版本

Use example for the "BREAK:" label

In this example, the total representing the sum of the last 10 invoices is displayed.

NbInvoices整数型
TotInv货币型

NbInvoices0
H读最后一个InvoiceInvNum
只要不H超出()
NbInvoice++
如果NbInvoices大于等于10,那么跳出// Jump directly to the BREAK: label
// Adds the invoices
TotInv+=Invoice.Amount

跳出:
// Exits from the loop after 10 iterations
信息"The total for the last 10 invoices is: "InvTtl
H读上一个InvoiceInvNum
结束

Use example for the "BREAK:" label

In this example, the total representing the sum of the last 10 invoices is displayed.

NbInvoices整数型
TotInv货币型

NbInvoices0
H读最后一个InvoiceInvNum
只要不H超出()
NbInvoice++
如果NbInvoices大于等于10,那么跳出// Jump directly to the BREAK: label
// Adds the invoices
TotInv+=Invoice.Amount

跳出:
// Exits from the loop after 10 iterations
信息"The total for the last 10 invoices is: "InvTtl
H读上一个InvoiceInvNum
结束

19版本和更高版本

"BREAK:" statement: Case of nested loops

When having several nested loops, you may have to exit from an iteration in order to go back to the previous level or even to a higher level.

To enable this, the 跳出 instruction accepts a parameter specifying the number of levels to go back up when breaking out. The syntax is as follows:

BREAK(<Number of Levels>)

where <Number of Levels> is an integer between 1 and N, N representing the number of nested levels for the loop.

For example:

xyz整数型

对于x1直到15// Loop 1
对于y1直到25// Loop 2
对于z1直到50// Loop 3
如果小于Myconditionchecked大于,那么
跳出(2// Exits from loop 3 and loop 2
// and goes to the next iteration in loop 1
结束
结束
结束
结束
19新版本

"BREAK:" statement: Case of nested loops

When having several nested loops, you may have to exit from an iteration in order to go back to the previous level or even to a higher level.

To enable this, the 跳出 instruction accepts a parameter specifying the number of levels to go back up when breaking out. The syntax is as follows:

BREAK(<Number of Levels>)

where <Number of Levels> is an integer between 1 and N, N representing the number of nested levels for the loop.

For example:

xyz整数型

对于x1直到15// Loop 1
对于y1直到25// Loop 2
对于z1直到50// Loop 3
如果小于Myconditionchecked大于,那么
跳出(2// Exits from loop 3 and loop 2
// and goes to the next iteration in loop 1
结束
结束
结束
结束

"BREAK:" statement: Case of nested loops

When having several nested loops, you may have to exit from an iteration in order to go back to the previous level or even to a higher level.

To enable this, the 跳出 instruction accepts a parameter specifying the number of levels to go back up when breaking out. The syntax is as follows:

BREAK(<Number of Levels>)

where <Number of Levels> is an integer between 1 and N, N representing the number of nested levels for the loop.

For example:

xyz整数型

对于x1直到15// Loop 1
对于y1直到25// Loop 2
对于z1直到50// Loop 3
如果小于Myconditionchecked大于,那么
跳出(2// Exits from loop 3 and loop 2
// and goes to the next iteration in loop 1
结束
结束
结束
结束