home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / QB45MULT.ZIP / SAMPMULT.BAS < prev   
BASIC Source File  |  1993-10-03  |  3KB  |  119 lines

  1. REM $INCLUDE: 'qb45mult.bi'
  2.  
  3. DIM SHARED CommandLine%
  4.  
  5. REM The functions getdoscursorx% and getdoscursory%  allow you to
  6. REM find where DOS parked the cursor when your routine was called.
  7. REM Call these BEFORE you do any printing or CLS. The POS function in basic
  8. REM does not report the DOS cursor, just Basic's. So I provided these.
  9.  
  10. REM checkinstalled% will tell you if a program using this LIB is
  11. REM already running. Sorry, at this point it can not tell if its
  12. REM the same program or not, just that one IS there.
  13. REM The choice is yours if you want to go ahead and install anyway.
  14. REM This MUST be called before gomult, or it will always report
  15. REM it's found one.
  16.  
  17. REM Find out if they want to go resident or not.
  18.  
  19. CommandLine% = VAL(COMMAND$)
  20.  
  21. IF checkinstalled% THEN
  22.     PRINT "Program already in memory."
  23.     END
  24. END IF
  25.  
  26. REM Pick our HotKey for the second Sub.
  27. REM In this case: Left Shift/F10
  28.  
  29. Hotkey1% = 68: KeyFlag1% = 2
  30.  
  31. sethotkeys Hotkey1%, KeyFlag1%
  32.  
  33. REM This installs the whole thing. When this is done, the basic sub
  34. REM 'basicstartup' is called once to set your routines up. From then on
  35. REM 'basicprocedure' is called every other time slice.
  36.  
  37. gomult CommandLine%
  38.  
  39. END
  40.  
  41. SUB basicprocedure
  42.  
  43. REM This sub is where your code goes that runs in the background.
  44. REM Keep in mind that the idea is to run unnoticed while
  45. REM the user is using his machine for other things. Try to keep memory
  46. REM usage as low as you can.
  47. REM This sample just pokes the time into the upper right corner of the screen.
  48.  
  49. SecondCount% = 0
  50. OldTime$ = TIME$
  51.  
  52. here:
  53. IF OldTime$ = TIME$ THEN GOTO here2
  54. OldTime$ = TIME$
  55. DEF SEG = &HB800
  56. Count% = 0
  57. FOR i% = 122 TO 136 STEP 2
  58. Count% = Count% + 1
  59. POKE i%, ASC(MID$(TIME$, Count%, 1))
  60. NEXT i%
  61.  
  62. here2:
  63. SecondCount% = SecondCount% + 1
  64. IF SecondCount% > 20 THEN SecondCount% = 1
  65. a$ = STRING$(20, CHR$(176))
  66. MID$(a$, SecondCount%, 1) = CHR$(219)
  67.  
  68. Count2% = 0
  69. FOR i% = 272 TO 310 STEP 2
  70. Count2% = Count2% + 1
  71. POKE i%, ASC(MID$(a$, Count2%, 1))
  72. NEXT i%
  73.  
  74. IF CommandLine% = 0 THEN yield
  75. GOTO here
  76.  
  77. END SUB
  78.  
  79. SUB basicprocedure2
  80.  
  81. REM This Sub is called when you press the hotkey. Background tasks are stopped.
  82. REM You can use this to exit, or to do some configuration, or whatever..
  83.  
  84. REM Call EXITMULT once, then exit the sub to activate it.
  85.  
  86. PRINT "I'm removing the program from memory."
  87.  
  88. exitmult
  89.  
  90. END SUB
  91.  
  92. SUB basicstartup
  93.  
  94. REM In this sub, put any code your routines need to perform only once.
  95. REM It is called before the background task switching begins, but after
  96. REM the kernal is installed. If you made it this far, you can be pretty
  97. REM sure all is ok.
  98.  
  99. CLS
  100.  
  101. LOCATE 5, 1
  102.  
  103. PRINT " This is a rather simple example of making a QB 4.5 program"
  104. PRINT "run in the background. We will just poke a clock into the "
  105. PRINT "upper right hand corner of the screen, and exit to the DOS prompt."
  106. PRINT : PRINT
  107. PRINT " Please press any key to begin..."
  108.  
  109. WHILE INKEY$ = "": WEND
  110.  
  111. PRINT "Background tasks installed."
  112. PRINT "All processes now running..."
  113. PRINT "LeftShift/F10 will remove from memory."
  114.  
  115. LOCATE , , 1
  116.  
  117. END SUB
  118.  
  119.