【问题标题】:Continue For Loop in OpenOffice Basic在 OpenOffice Basic 中继续循环
【发布时间】:2015-12-22 06:51:28
【问题描述】:

有没有办法像在其他语言中一样在 OpenOffice Basic 中继续循环?

For i = 0 To 10

  If i = 5 Then
     Continue For # Not working
  End If  

Next i

我知道语法 Exit For 可以打破循环,但我必须跳过一些迭代......提前谢谢你!

【问题讨论】:

  • 正如@tohuwawohu 所说,似乎没有任何这样的语法。见wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Loops。但是,使用 OpenOffice,您可以使用具有此功能的其他语言,例如 Java 或 Python。
  • @JimK:好点!我自己没有想到其他功能丰富的语言 - 值得回答......

标签: openoffice.org openoffice-basic


【解决方案1】:

AFAIK 没有,但您也可以使用 If 子句跳过某些迭代:

For i = 0 To 10

  If i <> 5 Then
     # Execute some commands except in the fifth iteration
  End If  

Next i

当然,使用类似Continue 的样式会更好,因为提议的If 子句似乎处理异常,而不是正常情况。

【讨论】:

    【解决方案2】:

    有同样的问题,通过将迭代器等同于自身来解决,即 i = i。

    【讨论】:

      【解决方案3】:
      For i = 0 To 10
      
        If i = 5 Then
           GoTo Continue 
        End If  
      
      
      Continue:
      Next i
      

      【讨论】:

        猜你喜欢
        • 2022-08-09
        • 2011-08-19
        • 2016-07-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多