home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / dataflex / timer.pkg < prev    next >
Encoding:
Text File  |  1993-08-10  |  4.4 KB  |  155 lines

  1. //************************************************************************
  2. //
  3. // Copyright 1987-1992 Data Access Corporation, Miami FL, USA
  4. // All Rights reserved
  5. // DataFlex is a registered trademark of Data Access Corporation.
  6. //
  7. //
  8. //     $Source: /u3/source.30/product/pkg/RCS/timer.pkg,v $
  9. //     $Revision: 1.1 $
  10. //     $State: Exp $
  11. //     $Author: james $
  12. //     $Date: 1992/09/08 14:43:09 $
  13. //     $Locker:  $
  14. //
  15. //     $Log: timer.pkg,v $
  16. //Revision 1.1  1992/09/08  14:43:09  james
  17. //Initial revision
  18. //
  19. //Revision 1.4  92/06/02  11:07:54  james
  20. //Rename global variables used by time_display command. One
  21. //was called MIN for minutes which then disabled the MIN 
  22. //operator.
  23. //
  24. //Revision 1.3  92/05/14  17:10:36  SWM
  25. //Updated Copyright slug.
  26. //
  27. //Revision 1.2  92/03/09  19:05:15  james
  28. //Added #CHKSUB directive to insure source
  29. //only compiled with correct revision of 
  30. //compiler.
  31. //
  32. //Revision 1.1  91/10/23  10:23:00  elsa
  33. //Initial revision
  34. //
  35. //************************************************************************/
  36.  
  37. //************************************************************************
  38. //     File Name: Timer.Pkg
  39. // Creation Date: January 1, 1991
  40. // Modified Date: May 23, 1991
  41. //     Author(s): Mike Zingman
  42. //
  43. // This module contains the symbols and commands used to manipulate object
  44. // event timers.
  45. //
  46. // Each timer is run off of the keyboard input loop.  You may have as many
  47. // timers as required in your application.  Each timer may have one of
  48. // several modes of operation.
  49. //************************************************************************/
  50.  
  51. #CHKSUB 1 1 // Verify the UI subsystem.
  52.  
  53. Use UI
  54.  
  55. //
  56. // define the constants needed for this package. 
  57. //
  58. #REPLACE NEW_TIMER    |CI0  // timer id for new timer
  59. #REPLACE TIMER_OFF    |CI0  // turn timer off
  60. #REPLACE ONE_SHOT     |CI1  // timer will fire only once
  61. #REPLACE PERIODIC     |CI2  // timer will fire once each period
  62. #REPLACE IDLE         |CI3  // timer will fire on inactivity
  63. #REPLACE TIMER_DELETE |CI4  // delete timer - reuse space
  64. #REPLACE DELETE_TIMER |CI4  // delete timer - reuse space (for old code)
  65.  
  66. //
  67. // Create or modify a timer.  This macro will create or modify the timer
  68. // specified by the Timer_Id.  If the id has not been defined, it will be
  69. // created automatically.  The valid mode for the timer is then specified.
  70. // Each mode will affect the timer in the above fashion.  Each timer must
  71. // have a object and message to generate.  The object may be any valid object
  72. // and must be able to handle the message generated on the timer event.  The
  73. // TIMER_OFF mode does not require the object or message parameters.
  74. //
  75. // Syntax:
  76. //
  77. //    Set_Timer Timer_Id [TIMER_OFF|ONE_SHOT|PERIODIC|IDLE|DELETE_TIMER] ;
  78. //        Object Message Period
  79. //
  80.  
  81. #COMMAND SET_TIMER RCDLBO# RDLBO#
  82.   #IFDEF !1
  83.   #ELSE
  84.     INTEGER !1
  85.     MOVE NEW_TIMER TO !1
  86.   #ENDIF
  87.   #DATA
  88.   #DPUSH !2        // TYPE
  89.   #IF (!0>2)
  90.     #CHECK !3 RDLOB
  91.     #CHECK !4 RDLOB
  92.     #CHECK !5 RDLOB
  93.     #IFDEF !3
  94.       #DPUSH !3        // NOTIFY
  95.     #ELSE
  96.       #IFDEF !3.OBJ
  97.         #DPUSH !3.OBJ
  98.       #ELSE
  99.         #DPUSH |CI0
  100.         #FREF !3.OBJ !a,1
  101.       #ENDIF
  102.     #ENDIF
  103.     #IFDEF !4
  104.       #DPUSH !4        // MESSAGE
  105.     #ELSE
  106.       #IFDEF MSG_!4
  107.         #DPUSH MSG_!4
  108.       #ELSE
  109.         #DPUSH |CI0
  110.         #FREF MSG_!4 !a,2
  111.       #ENDIF
  112.     #ENDIF
  113.     #DPUSH !5        // ALARM TIME
  114.   #ELSE
  115.     SEND$HELP 0 0 0
  116.   #ENDIF
  117.   !A [] OBJ$TIMER !1 |VL
  118. #ENDCOMMAND
  119.  
  120. //
  121. // This is a nice little macro for displaying the date and time of day on
  122. // the bottom of the screen.  The macro will automatically create its own
  123. // timer and global procedure to receive the timer message.  The time data
  124. // will be formatted by the macro.  The ON/OFF parameter will control whether
  125. // the timer will display.
  126. //
  127. // Syntax:
  128. //    Time_Display [ON|OFF]
  129. //
  130.  
  131. #COMMAND TIME_DISPLAY "ON""OFF" .
  132.   #IFDEF MSG_SHOW_TIME
  133.   #ELSE
  134.     PROCEDURE SHOW_TIME
  135.       LOCAL DATE TODAY
  136.       STRING HOURS MINUTES SECONDS
  137.       SYSDATE TODAY HOURS MINUTES SECONDS
  138.       GOTOXY (SCREENEND-1) 60
  139.       SHOW TODAY ' ' (RIGHT('0'+HOURS,2)) ':' (RIGHT('0'+MINUTES,2)) ':' (RIGHT('0'+SECONDS,2))
  140.     END_PROCEDURE
  141.   #ENDIF
  142.   #IFSAME !1 ON
  143.     SET_TIMER DISPLAY$TIMER$ID PERIODIC DESKTOP SHOW_TIME 100
  144.   #ELSE
  145.     SET_TIMER DISPLAY$TIMER$ID TIMER_OFF
  146.     CLEARXY (SCREENEND-1) 60    // REMOVE THE DISPLAY
  147.   #ENDIF
  148. #ENDCOMMAND
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.