DO 12.2.3 comes with Dialog.SetTimer/Dialog.KillTimer without an example, could someone please give me one about how to use it in VBScript/JScript? Thanks in advance!
Here's an example that creates a simple clock.
Clock.dcf (1.84 KB)

The script code looks like this:
Option Explicit
Function OnClick(ByRef clickData)
Dim Dlg, Msg, Timer
Set Dlg = DOpus.Dlg
Dlg.template = "clock"
Dlg.detach = True
Dlg.Show
Timer = Dlg.SetTimer(1000)
Do
Set Msg = Dlg.GetMsg()
if Msg.event = "timer" Then
DOpus.Output "tick"
Dlg.Control("time").label = FormatDateTime(Now, vbLongTime)
end if
Loop While Msg
End Function
Thank you very much for your help, Jon!
If someone wants to try this example without using the Clock.dcf, don't forget to copy the resources:
<resources>
<resource name="clock" type="dialog">
<dialog fontsize="20" height="21" lang="english" width="60">
<control halign="left" height="8" name="time" type="static" width="48" x="6" y="6" />
</dialog>
</resource>
</resources>
God damn, I was breaking my head to try and figure out how they worked.
"Are they trying to call an OnTimer or OnScheduledTimer method? Is there a global timers object where callbacks can be registered by name? ..."
Can you please add in the docs that the timer events we're talking about are Msg events as returned by Dialog.GetMsg() with
event: "timer",
control: "<timerName>"
?
I've added a note to the SetTimer docs.
1 Like
Neato! Thank you, mr. lightning! ![]()