Writing scripts

Using asynchronous methods and subroutines in scripts

Use the following guidelines when using asynchronous methods or subroutines (Close method, ClosePicture subroutine, ReplaceDocument method, ReplacePicture subroutine, or SwitchMode method) in your scripts:

Private Sub Rect1_Click()
    ClosePicture "Tank1"
    DoEvents
    OpenPicture "Tank2"
End Sub

Performing String Comparisons

When performing a string comparison using the A_SCAN or A_ENAB field, you must include a trailing space in the comparison string. For example, in the following sample script, the trailing space is required in the comparison strings for the test to work correctly.

Private Sub CommandButton4_Click()

    If (Fix 32.DVSYS.A_SCAN = "OFF ") Then
        Fix 32.DVSYS.AI1.A_SCAN = "ON "
    Else
        Fix 32.DVSYS.AI1.A_SCAN = "OFF "
    End If

End Sub