A simple polling interval section can be added to any screen to which polling applies.
An invisible timer issues a poll command on the specified polling interval for a specified duration, then stops. The Polling Duration drop-down menu also has an option to poll indefinitely on the given interval.
The following example shows how an auto polling control panel can be set up.
To Add Automatic Polling to a Screen
|
Sub chkEnable_EventInitialize() Dim This : Set This = chkEnable this.Check = 0 End Sub |
|
Sub cboInterval_EventInitialize() Dim This : Set This = cboInterval This.Selection = 0 End Sub |
|
Sub cboDuration_EventInitialize() Dim This : Set This = cboDuration This.Selection = 0 End Sub |
|
Sub chkEnable_EventChange() Dim This : Set This = chkEnable If This.Check = True Then timer.Enabled1 = True timer.Enabled2 = True strTime = FormatDateTime(Now(),0) If cboDuration.Selection = 0 Then '1 minute timer.Interval2 = (60 * 1000) End If If cboDuration.Selection = 1 Then '2 minutes timer.Interval2 = (120 * 1000) End If If cboDuration.Selection = 2 Then '5 minutes timer.Interval2 = (300 * 1000) End If If cboDuration.Selection = 3 Then 'Indefinitely timer.Interval2 = (500 * 1000) End if Else timer.Enabled1 = False timer.Enabled2 = False End If End Sub |
|
Sub cboDuration_EventChange() Dim This : Set This = cboDuration If This.Selection = 0 Then '1 minute timer.Interval2 = (60 * 1000) End If If This.Selection = 1 Then '2 minutes timer.Interval2 = (120 * 1000) End If If This.Selection = 2 Then '5 minutes timer.Interval2 = (300 * 1000) End If If This.Selection = 3 Then 'Indefinitely timer.Interval2 = (500 * 1000) End if End Sub |
|
Sub cboInterval_EventChange() Dim This : Set This = cboInterval If This.Selection = 0 Then '5 seconds timer.Interval1 = (5 * 1000) End If If This.Selection = 1 Then '10 seconds timer.Interval1 = (10 * 1000) End If If This.Selection = 2 Then '30 seconds timer.Interval1 = (30 * 1000) End If End Sub |
|
Sub timer_EventOnTimer1() Dim This : Set This = timer On Error Resume Next If inTimer = False Then inTimer = True btnPoll.RunClick inTimer = False End If End Sub |
|
Sub timer_EventOnTimer2() Dim This : Set This = timer If cboDuration.Selection <> 3 Then Timer.Enabled1 = False End If End Sub |
|
'(Declarations)
Dim inTimer
Sub DoPoll() 'Custom poll logic End Sub
'End of (Declarations) |
This example can be extended in a number of ways. A Button can be added to poll immediately, or a Label can be added to show a countdown until the current poll duration will stop.