I'm using the Terminal Emulator to provide access to a Support BBS. I want to automate the log on process using WaitForString. It isn't working. WaitForString always "times out", and I know for a fact that the Host is sending the String that I'm waiting for.

The Terminal Emulator turns on Receive Notification to its Client Window. This means that the Terminal Window Procedure will always get first stab at any incoming characters. In 16 Bits, Windows sends a Notification message directly to the Window Procedure. In 32 Bits, CLACom starts a Background Thread that waits for Communications Events. When a character is received, this Thread sends a Notification message to the Window Procedure.

WaitForString will never "see" any characters while the Terminal Window is active. This is because the Terminal Procedure has already removed the characters from the Receive Buffer.

All is not lost however. You can temporarily disable Receive Notification to the Terminal Window, wait for a String to arrive, send your Response, and then re-enable Receive Notification.

This is similar to what the File Transfer routines do, since they need to have access to the Receive Buffer.

If AutoLogOn
   ! Don't let Terminal have any
   ! Characters until we have logged on
   CLATermPrepareTransfer(CLATermPort,0)
   ! Wait for User ID Prompt
   ! If String doesn't Arrive
   ! Display an Error Message
   ! and Close the Terminal Window
   If WaitForString(AppWin,CLATermPort,'USER ID',20)
      Do NobodyHome
      Post(Event:CloseWindow)
   Else
      ! We received the Log On Prompt
      ! Now send the User Id
      TmpCString = 'MyUserID^M'
      ModemPuts(CLATermPort, TmpCString)
      ! Clear any remaining characters
      ClrRecvBuf(CLATermPort)
      ! Re-Enable Notification Thread
      CLATermPrepareTransfer(CLATermPort,1)
   End
End