I see how a search on string "timer" in IDL Online Help takes you first to this IDL_TimerSet. And, if you are not an "external development" programmer (a programmer that interfaces IDL to other computer languages) it is not easy to see that 'IDL_TimerSet' is a C function, not an IDL routine.
You need to be rather working with WIDGET_TIMER, not an easy subject to find in IDL Online Help. The link is through the 'Index' tab of Help ('timers -> widget timer') or through a general Help Search for the topic "Working with widget events", where "Timer Events" is a subtopic.
Here is an example that I wrote several years ago:
; File: 'button_and_timer.pro'
; Syntax: BUTTON_AND_TIMER
; Purpose: Demonstrate timer events juxtaposed with button events
; Instructions: This program starts a widget with one button in its center.
; Pressing the button causes "You pressed me" to be IMMEDIATELY
; printed in the IDL output log. Besides this, a timer event attached to
; the top-level base will print to the IDL output log "Timer just triggered"
; every 2 seconds.
; Event handler code
PRO button_and_timer_event, event
; Handle the timer event
if tag_names(event, /STRUCTURE_NAME) eq 'WIDGET_TIMER' then begin
print, 'Timer just triggered'
widget_control, event.top, timer=2.0
endif
; Handle the button event
if tag_names(event, /STRUCTURE_NAME) eq 'WIDGET_BUTTON' then begin
print, 'You pressed me'
endif
END
; Widget creation code
PRO button_and_timer
tlb = widget_base(/COLUMN, /BASE_ALIGN_CENTER, XSIZE = 240, $
YSIZE=50, TITLE='Base w/Button & Timer')
wButton = widget_button(tlb, value='Press Me')
widget_control, tlb, /realize, timer=2.0
xmanager, 'button_and_timer', tlb
END
James Jones
|