home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / basic / pbvl010.zip / MTIMER.BAS < prev    next >
BASIC Source File  |  1994-02-10  |  3KB  |  109 lines

  1. '┌─────────────────────────────────────────────────────────────────────────┐
  2. '│    FILE: MTIMER.BAS                                                     │
  3. '│ PURPOSE: PB/VISION(tm) LITE Example Program                             │
  4. '├─────────────────────────────────────────────────────────────────────────┤
  5. '│ PURPOSE: Demonstrates the "TimerInstallCode()" routine that allows a    │
  6. '│          single user defined function to be called up to 18 times per   │
  7. '│          second, no matter what window is in focus.                     │
  8. '├─────────────────────────────────────────────────────────────────────────┤
  9. '│ For instant help on any PB/VISION(tm) keyword, place the cursor on that │
  10. '│ keyword and press <CTRL-F1>.  The PB/VISION(tm) index can be accessed   │
  11. '│ by pressing <SHIFT-F1> twice.  The file "PBVLITE.PBH" _must_ be in the  │
  12. '│ same directory as the PowerBASIC IDE (PB.EXE) for this feature to work  │
  13. '│ properly.                                                               │
  14. '└─────────────────────────────────────────────────────────────────────────┘
  15.  
  16. '       ==================================================
  17. '    BE SURE TO RUN "DEMO.EXE" FOR INFORMATION ON OTHER
  18. '       PowerBASIC 3.0 TOOLS FROM DSE SOFTWARE PUBLISHING.
  19. '       ==================================================
  20.  
  21. %ISPBU = 0
  22.  
  23. $INCLUDE ".\WINDOW.BI"
  24. $INCLUDE ".\EVENT.BI"
  25. $INCLUDE ".\MOUSE.BI"
  26.  
  27.     $STACK 8192
  28.  
  29.     DEFINT A-Z
  30.     $DYNAMIC
  31.  
  32.     %timeOut = 1001
  33.  
  34.     SHARED SH%, A, B, C, D
  35.  
  36.     MTIMER.INIT    ' initialize the demo interface
  37.     MTIMER.RUN    ' run the interface
  38.     MTIMER.DONE    ' terminate program
  39.     END
  40.  
  41. SUB MTIMER.INIT
  42.  
  43.     app.attr = &H87
  44.     app.pattern = 32
  45.     app.GraphicsMouse = 1
  46.     app.GraphicsMode = 1
  47.  
  48.     APPTITLE &H70, "MTIMER.BAS - DEMO PROGRAM FOR TimerInstallCode( ) ROUTINE"
  49.  
  50.     APPINIT
  51.  
  52.     GottaMouse% = MOUSEINIT(buttons%)    ' initizlize mouse
  53.     MOUSECURSORON                         ' turn it on
  54.  
  55.     A = WINPOPUP (3,  5, 10, 40, &H9F, 1, &H9F, "MTIMER.BAS - LOOK AT THE TITLE BAR", &HE0, %DRAGBAR OR %SHADOW)
  56.     B = WINPOPUP (5, 10, 10, 40, &HA7, 1, &HA8, "MTIMER.BAS - LOOK AT THE TITLE BAR", &HCF, %DRAGBAR OR %SHADOW)
  57.     C = WINPOPUP (7, 15, 10, 40, &HF1, 1, &HF1, "MTIMER.BAS - LOOK AT THE TITLE BAR", &H9F, %DRAGBAR OR %SHADOW)
  58.     D = WINPOPUP (9, 20, 10, 40, &HCF, 1, &HCF, "MTIMER.BAS - LOOK AT THE TITLE BAR", &HB0, %DRAGBAR OR %SHADOW)
  59.  
  60.     TIMERINSTALLCODE CODESEG(MyTimerRoutine), CODEPTR(MyTimerRoutine)
  61.  
  62. END SUB
  63.  
  64. SUB MTIMER.RUN
  65.  
  66.     DO
  67.         eventNo = GetEvent(0)
  68.  
  69.         SELECT CASE eventNo
  70.  
  71.             CASE 102
  72.                 EXIT SUB
  73.  
  74.             CASE %timeOut
  75.                 WINWRITE D, "%timeOut event, "
  76.  
  77.         END SELECT
  78.  
  79.     LOOP
  80.  
  81. END SUB
  82.  
  83. SUB MTIMER.DONE
  84.     MOUSECURSOROFF
  85.     APPCLOSE
  86.     END
  87. END SUB
  88.  
  89. FUNCTION MyTimerRoutine% (BYVAL UpdateOk%) PUBLIC
  90.  
  91.     ' NOTE: If "UpdateOk%" = 0, it is _not_ safe to update the
  92.     '       screen.  Only when "UpdateOk%" = 1 is it safe to
  93.     '       use any routines that will change the display.
  94.  
  95.     STATIC char%, count%
  96.  
  97.     INCR count%
  98.  
  99.     char = char MOD 4 + 1
  100.  
  101.     COLOR 0, 7: LOCATE 1, 59: PRINT MID$("|/-\", char, 1);
  102.  
  103.     IF count% = 9 THEN
  104.                count% = 0
  105.         MyTimerRoutine% = %timeOut
  106.     END IF
  107.  
  108. END FUNCTION
  109.