Example

Here's a procedure that waits for the user to press F4. If WaitEvent times out before a PF4 is pressed, an error is returned and the error handler kicks in:

Sub WaitForF4 ()

 Dim eventF4 As Integer

 With Session

  On Error Goto Handler

  .DefineEvent 1, rcTerminalKeystroke, "", "", 1, 1, rcIbmPf4Key

  eventF4 = .WaitEvent("0:0:10")

  MsgBox "Event = " & eventF4

 End With

 Exit Sub

 

Handler:

 MsgBox "The F4 keystroke was not pressed."

 Exit Sub

 

End Sub