LOTUSSCRIPT 言語
構文は次の通りです。
On expression GoTo label, [ , label ]...
このステートメントは、expression の値に基づいてジャンプ先のラベルに制御を移します。expression が 1 であれば最初の label へ、expression が 2 であれば、2 番目の label へ、というように制御が移ります。
On...GoTo とそのジャンプ先のラベル付きステートメントは、同じプロシージャ内になければなりません。制御のフローは実行時に決まります。
次のサブルーチンは On...GoTo を使用して、LotusScript の 2 つの単純なパフォーマンステストのいずれかを実行します。入力ボックスに 1 か 2 を入力することにより、Do ループの 1000 回繰り返しの時間測定と、1 秒間に実行される Yield ステートメント数のカウントのどちらかをユーザーが選択します。スクリプトは On...GoTo を使用して選択されたテストへ分岐して実行し、結果を表示します。
Sub RunPerfTest Dim directTempV As Variant, directTest As Integer, _ i As Integer Dim startTime As Single SpecTest:directTempV = InputBox$(|Type 1 for iteration time, or 2 for # of yields:|) If Not IsNumeric(directTempV) Then Beep :GoTo SpecTest directTest% = CInt(directTempV) If directTest% < 1 Or directTest% > 2 _ Then Beep :GoTo SpecTest i% = 0 ' Branch on 1 or 2. On directTest% GoTo TimeCheck, ItersCheck TimeCheck:startTime!= Timer() Do While i% <= 1000 i% = i% + 1 Loop Print "Time in seconds for 1000 iterations:" _ Timer() - startTime! Exit Sub ItersCheck:startTime!= Timer() Do Yield i% = i% + 1 Loop While Timer() < startTime!+ 1 Print "Number of Yields in 1 second:" i% End Sub Call RunPerfTest()
サブルーチン RunPerfTest を 3 回実行した結果は、LotusScript を実行しているコンピュータの速度にもよりますが、次のような結果になります。
'Output: ' (With input 2) Number of Yields in 1 second:975 ' (With input 1) Time in seconds for 1000 iterations:.109375 ' (With input 2) Number of Yields in 1 second: 952
関連項目