OpenVMS Source Code Demos
TIMER_DEMO_HARD.BAS
1000 %title "basic-timer-demo-hard_xxx.bas" !
%ident "version 100.1" ! <<<---+---
declare string constant k_version = "100.1" , ! <<<---+ &
k_program = "basic-timer-demo-(hard)" !
!=======================================================================
! title : basic-timer-demo-hard.bas
! author : Neil Rieck ( https://neilrieck.net/ )
! created: 2010-04-08
! ver who when what
! --- --- -------- -----------------------------------------------------
! 100 NSR 20100408 1. original program (the hard way)
!=======================================================================
option type=explicit !
%include "starlet" %from %library "sys$library:basic$starlet" ! system services
%include "$ssdef" %from %library "sys$library:basic$starlet" ! ss$
%include "lib$routines" %from %library "sys$library:basic$starlet" ! lib$
!
declare long event_flag_timer ,&
long rc% ,&
basic$quadword DeltaQuad1
declare string delay$ !
!=======================================================================
! main
!=======================================================================
main:
print k_program +"_"+ k_version !
print string$(len(k_program +"_"+ k_version), asc("=")) !
!
rc% = lib$get_EF(event_flag_timer by ref) !
if rc% <> ss$_normal then !
print "-e- oops, couldn't allocate an event flag" !
goto fini !
end if !
!
print "starting 100ms delay" !
gosub delay100ms !
print "wake"
!
print "starting 500ms delay" !
gosub delay500ms !
print "wake" !
!
print "starting 900ms delay" !
gosub delay900ms !
print "wake" !
!
print "starting 750ms delay" !
delay$ = "0 00:00:00.75" ! delay 0.75 seconds
gosub delay_common !
print "wake" !
!
goto fini !
!-----------------------------------------------------------------------
! various delays
!-----------------------------------------------------------------------
delay100ms: !
delay$ = "0 00:00:00.1" !
goto delay_common !
!
delay500ms: !
delay$ = "0 00:00:00.5" ! delay 0.5 seconds
goto delay_common !
!
delay900ms: !
delay$ = "0 00:00:00.9" ! delay 0.9 seconds
goto delay_common !
!
! note: delay$ must be set up before this entry point
!
delay_common: !
rc% = sys$bintim(delay$, DeltaQuad1 ) ! convert delay to 64-bit binary
print "-e- sys$bintim rc: "+ str$(rc%) if ((rc% and 1%) <> 1%) !
rc% = sys$setimr(event_flag_timer,DeltaQuad1 by ref,,,) ! now use it to schedule a wake up
print "-e- sys$setimr rc: "+ str$(rc%) if ((rc% and 1%) <> 1%) !
!
! <<< wait for the event flag to change state >>>
!
rc% = sys$waitfr( event_flag_timer ) ! wait for a response from a single flag
print "-e- sys$waitfr rc: "+ str$(rc%) if ((rc% and 1%) <> 1%) !
!
! <<< cancel the timer requests (if any) >>>
!
rc% = sys$cantim(,) ! cancel all timer requests (propbably not req'd)
print "-e- sys$cantim rc: "+ str$(rc%) if ((rc% and 1%) <> 1%) !
return !
!=======================================================================
! that's all folks
!=======================================================================
fini: !
end !
Back to
Home
Neil Rieck
Waterloo, Ontario, Canada.