View Single Post
  #4  
Old 09-14-2015, 10:34 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Peter,

You can modify the code example that I provided to work with the Send() and WaitForString() methods, but that will expand your code unnecessarily. You may consider moving the Send() and WaitForString() methods into functions. Here are a couple of example functions:
Code:
Set g_objTab = crt.GetScriptTab
Set g_fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Set g_objErrLog = g_fso.OpenTextFile("C:\Documents and Settings\vdt-csg\Desktop\" & g_objTab.Caption & ".Err.log", ForWriting, True)

Send("ls" & vbcr)
Wait("#")

Function Send(strString)
    Send = True
    On Error Resume Next
    g_objTab.Screen.Send strString
    nError = Err.Number
    strError = Err.Description
    On Error Goto 0
    If nError <> 0 Then
        g_objErrLog.Write "SEND error(" & nError & "): " & strError & vbcrlf
        Send = False
        Exit Function
    End If
End Function

Function Wait(strString)
    Wait = True
    On Error Resume Next
    g_objTab.Screen.WaitForString strString
    nError = Err.Number
    strError = Err.Description
    On Error Goto 0
    If nError <> 0 Then
        g_objErrLog.Write "WAIT error(" & nError & "): " & strError & vbcrlf
        Wait = False
        Exit Function
    End If
End Function
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote