title: Attachmate receive host string and react with conditional response using VBA
body: <p>Using Attachmate, I am trying to write a VBA script that reacts when a specific phrase occurs and automatically executes commands via inline commands.  Essentially, when a phrase appears, an inputbox appears asking the user for a specific quantity and the VBA code takes that quantity, inserts it into the terminal and then jumps around different menus to create an internal label.  However, my problem is that I don't know how to have the VBA code react to the different strings that may be returned by the host.  Sometimes it says "enter to continue" and sometimes it says "select user".  So what I want it to do is based on the statement it receives to do a certain action, but I don't know what the command is for capturing what the terminal is receiving from the host.  I've tried "waitforstring" and "readline" but it is obvious I am not using them correctly.  Below is the code I have built thus far, please be gentle as it is still very unfinished.  I have commented out several parts of it in attempts to troubleshoot my problems:</p>
  
  <pre><code>'variable declarations
  Dim count As Long 'var used to indicate how many times code should loop (how many labels should be print)
  Dim drugname As String
  Dim qtyinput As Long
  Dim CR As String    ' Chr(rcCR) = Chr(13) = Control-M
  Dim LF As String    ' Chr(rcLF) = Chr(10) = Control-J
  Dim strcheck As String
  
  'assign values to variables
  count = 0
  CR = Chr(Reflection2.ControlCodes.rcCR)
  LF = Chr(Reflection2.ControlCodes.rcLF)
  
  qtyinput = InputBox("Number of items being sent", Quantity)
  drugname = .GetText(22, 15, 22, 46) ' StartRow:=22, StartColumn:=15,EndRow:=22,   EndColumn:=46 'copies text from screen
      ' Press EditCopy (Copy the selection and put it on the Clipboard).
      '.Copy rcSelection, rcAsPlainText -- not needed
  .Transmit qtyinput &amp; CR
  .Transmit CR
  'strcheck = .readline("00:00:01")
  'MsgBox strcheck
  'If .WaitForString("Press " &amp; Chr(34) &amp; "RETURN" &amp; Chr(34) &amp; " to continue, " &amp; Chr(34) &amp; "^" &amp; Chr(34) &amp; " to stop: ") Then .Transmit CR
  
  'Select Case strcheck
  '    Case strcheck Like "to continue"
  '        .Transmit CR
      'Case strcheck Like "*Select CLIENT*"
      '    .Transmit CR
  'End Select
  
  .Transmit "^MED" &amp; CR
  .Transmit "3" &amp; CR
  .Transmit "10" &amp; CR
  </code></pre>