0

モーターを制御する LotusScript を作成しようとしています。ビットを読み取るためのスクリプトは正常に動作しているようですが、停止ボタンを追加したいと考えています。デバイスを停止させるコマンドはすべて揃っていますが、問題は、LotusScript がループを実行しているときに他のボタンをクリックできないことです。

誰もこれを回避する方法を知っていますか???

私が使用しているスクリプトは以下のとおりです。

よろしくお願いします。

アンディ・バーロウ

Sub readpositionsub Dim send_string As String
Dim readString As String Dim tempString As String readString = ""

REM Sets the "movement" cell to 6 (the movement int)
[b1].contents = "6"
Do While [b1].contents <> "7"

    readString = ""
    statusBitString = ""

    REM READ STATUS ===!!!===
    REM Open the handle to the motor
    handle =    init_RS232(19200)
    REM #1$ reads the status from the controller.
    send_string = "#1$"+Chr$(13)
    REM Ask the controller to store the results in bits
    resultStatus=write_RS232 (handle,send_string)

    REM Read Status by looping through all of the bits
    For n=0 To 8
        tempString = "*1234567"  
        sendReadCommand = read_RS232(handle,tempString)
        If Mid(tempString,1,1) = Chr$(13) Then
            Exit For
        Else
            statusBitString = statusBitString  + Mid(tempString,1,1)
        End If

    Next
    [b1].contents = Mid(statusBitString,7, 1)
    close_RS232(handle)
    REM End Read Status



    REM READ POSITION ===!!!===
    REM Open the handle to the motor
    handle =    init_RS232(19200)
    send_string = "#1C"+Chr$(13)
    t=write_RS232 (handle,send_string)  
    REM Reading Position
    For n=0 To 20
        tempString = "*1234567"  
        r = read_RS232(handle,tempString)
        If Mid(tempString,1,1) = Chr$(13) Then
            Exit For
        Else
            readString = readString + Mid(tempString,1,1)

        End If

    Next
    REM End Read Position
    [a1].contents=Mid(readString, 4)
    close_RS232(handle)

Loop

サブ終了

そして、機能するはずの停止ボタンは... Object btnStop

Sub Click(Source As Buttoncontrol) REM 初期化ハンドル = init_RS232(19200)

REM Create the string for starting the motor
send_string = "#1S"+Chr$(13)

REM Send the string for starting the motor
resultStartMotor=write_RS232 (handle,send_string)

REM Close the spin handle
close_RS232(handle)

サブ終了

4

2 に答える 2

1

スレッド化された環境で Lotusscript を実行していないのに、ボタンのコードが既に実行中のコードをどのように停止すると予想しますか?

于 2010-03-03T01:51:05.090 に答える
1

ループをキャンセルできるようにしたい場合は、タイマー オブジェクトを操作する必要があります。基本的に、ループの 1 回の反復を実行する時間を開始します。最初に、変更されたフィールド値または ini 変数を探して、タイマーが設定されている場合はキャンセルします。これで、ボタンを使用してその変数を設定できます。ループは、タイマーがない場合よりもはるかに遅く実行されます(設定した待機間隔があるため)

于 2010-03-05T04:07:55.103 に答える