Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - timerentry() install a procedure to periodically execute http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 timerentry()        Install a procedure to periodically execute
------------------------------------------------------------------------------
 Declaration
   tsr.hdr

 Syntax
   func logical timerentry extern
   param       untyped xProcedure, ;
         value long    gTimeVal, ;
         value int     iTimeType, ;
         value uint    uCallType

 Arguments
   xProcedure is the function to install.
   gTimeVal is the time interval between invokations.
   iTimeType specifies the measure used in specifying gTimeVal.
   uCallType is the call type.

 Return
   A logical indicating if the function could successfully be installed.

 Description
   The timerentry() function establishes a procedure to be called in a
   periodic manner. The timerentry() function is helpful in
   programming tasks that are typically accomplished in a "wait for a
   key" procedure, such as printing the current time in the upper right
   hand corner of the screen.

   The procedure installed by timerentry() is not active until either the
   tsr() or the activateprocs() procedure is invoked. A program may have more
   than one timer procedure.

   The iTimeType parameter specifies how the value given in gTimeVal is
   interpreted. See the TSR table for possible values.

   uCallType specifies when it is safe for the procedure to be invoked. This is
   necessary to define because DOS could be in the middle of a disk
   operation when procedure is called, leaving DOS in an unstable state.
   See the TSR table for possible values.

 Example
   #define EXAMPLE_SYSTEM
   #include example.hdr

   proc DispTime static
   // "Interrupt routine" which will display the time
   saverc()           // save the cursor position for later restore
   @ 4, 5 ?? time()   // display time
   restrc()           // restore the cursor position
   endproc
   
   proc Test_timerentry
   vardef
      uint i
      uint uKey
   enddef
   
   clear
   cursoroff()
   
   // DispTime() is hooked in the timer interrupt chain
   timerentry( DispTime, 1, TSR_TIME_SECS, TSR_CALL_DOS )
   
   @ 10, 5 ?? "Press 'T' to start the time display"
   @ 11, 5 ?? "      'S' to stop  the time display"
   @ 12, 5 ?? "      Esc to quit  the demo."
   
   i := 0
   
   do while .t.
      @ 7, 0 ?? i
      i++
      uKey := inkey()
      do case
      case toupper( uKey ) == 'T'
         activateprocs()
      case toupper( uKey ) == 'S'
         deactivateprocs()
         @ 4, 5 ?? space( 8 )
      case uKey == K_ESC
         exit
      endcase
   enddo
   
   deactivateprocs()
   cursoron()
   clear
   endproc

   proc main
   Test_timerentry()
   endproc

See Also: TSR table activateprocs() tsr()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson