LOTUSSCRIPT 言語


End ステートメントを使用してプロシージャの実行を早期に停止する
End ステートメントは、現在のプロシージャの実行を終了し、同時に現在のプロシージャを呼び出した一連の呼び出しにおけるすべてのプロシージャの実行を終了します。

構文は次の通りです。

End [ returnCode ]

オプション returnCode は整数式です。このステートメントが現れるスクリプトは、スクリプトを実行した Lotus ソフトウェアアプリケーションにこの式の値を返します。End ステートメントが実行されたときに製品が戻り値を期待しているかどうかを判断するには、その製品のマニュアルを参照してください。戻りコードが期待されていない場合は、End ステートメントで戻りコードを指定しないでください。

次の例では、サブルーチン DoTimer が呼び出され、これは次にサブルーチン ElapsedTime を呼び出します。ElapsedTime で End ステートメントが実行されると、DoTimer 呼び出しの次の Print ステートメントから実行が続行されます。

' Compute the time to run some number of iterations of a For
' loop, and the time to execute the ElapsedTime sub.
Dim anInt As String
Public startSub As Single, startLoop As Single
Public counter As Long
Sub ElapsedTime
  ' If 0 or negative number of iterations is specified,
  ' print a message and end execution.
  If counter& <= 0 Then
     Print "Number of iterations must be >0"
     End                        ' End execution
  End If
  startLoop!= Timer()
  For doCount& = 1 To counter&
  Next
  Print Timer() - startLoop!"seconds to run" counter& _
    "iterations"
End Sub
Sub DoTimer
  ' DoTimer calls ElapsedTime and reports the result.
  anInt$ = InputBox$("Enter a whole number:")
  counter& = CLng(anInt$)
  startSub!= Timer()
  Call ElapsedTime()
  ' This Print statement will not be executed if the End
  ' statement in sub ElapsedTime was executed.
  Print Timer() - startSub!"seconds for ElapsedTime sub call"
End Sub
Call DoTimer()
' Sample output, for 5000 iterations requested by user:
' .109375 seconds to run 5000 iterations
' .1601563 seconds for ElapsedTime sub call
' Output for -1000 iterations requested by user:
' Number of iterations must be >0

関連項目