Remote Control
R&S
®
ESRP
969
User Manual 1175.7445.02 ─ 08
event has not yet occurred. In this way, the system can respond to user inputs (mouse
clicks, key entries) during the waiting time.
It is advisable to employ the Hold() auxiliary function, which returns control to the oper-
ating system for a selectable waiting time (see section
), so enabling user inputs during the waiting time.
result% = 0
For i = 1 To 10 'Abort after max. 10 loop
'iterations
Status = viWaitOnEvent(analyzer, VI_EVENT_SERVICE_REQ, VI_TMO_IMMEDIATE, VI_NULL,
VI_NULL)
'Check event queue
If (status = VI_SUCCESS) Then
result% = 1
CALL Srq 'If SRQ is recognized =>
'subroutine for evaluation
Else
CALL Hold(20) 'Call hold function with
'20 ms 'waiting time. User inputs
'are possible.
Endif
Next i
If result% = 0 Then
Debug.Print "Timeout Error; Program aborted"'Output error message
STOP 'Stop software
Endif
11.17.1.3
Waiting Without Blocking the Keyboard and Mouse
A frequent problem with remote control programs using Visual Basic is to insert waiting
times without blocking the keyboard and the mouse.
If the program is to respond to user inputs also during a waiting time, control over the
program events during this time must be returned to the operating system. In Visual
Basic, this is done by calling the
DoEvents
function. This function causes keyboard-or
mouse-triggered events to be executed by the associated elements. For example, it
allows the operation of buttons and input fields while the user waits for an instrument
setting to be completed.
The following programming example describes the
Hold()
function, which returns
control to the operating system for the period of the waiting time selectable in millisec-
onds.
Rem ***********************************************************************
Rem The waiting function below expects the transfer of the desired
Rem waiting time in milliseconds. The keyboard and the mouse remain
Rem operative during the waiting period, thus allowing desired elements
Rem to be controlled
Rem ***********************************************************************
Public Sub Hold(delayTime As Single)
Start = Timer 'Save timer count on calling the
Remote Control – Programming Examples