home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
QBAS
/
QB45MULT.ZIP
/
SAMPMULT.BAS
< prev
Wrap
BASIC Source File
|
1993-10-03
|
3KB
|
119 lines
REM $INCLUDE: 'qb45mult.bi'
DIM SHARED CommandLine%
REM The functions getdoscursorx% and getdoscursory% allow you to
REM find where DOS parked the cursor when your routine was called.
REM Call these BEFORE you do any printing or CLS. The POS function in basic
REM does not report the DOS cursor, just Basic's. So I provided these.
REM checkinstalled% will tell you if a program using this LIB is
REM already running. Sorry, at this point it can not tell if its
REM the same program or not, just that one IS there.
REM The choice is yours if you want to go ahead and install anyway.
REM This MUST be called before gomult, or it will always report
REM it's found one.
REM Find out if they want to go resident or not.
CommandLine% = VAL(COMMAND$)
IF checkinstalled% THEN
PRINT "Program already in memory."
END
END IF
REM Pick our HotKey for the second Sub.
REM In this case: Left Shift/F10
Hotkey1% = 68: KeyFlag1% = 2
sethotkeys Hotkey1%, KeyFlag1%
REM This installs the whole thing. When this is done, the basic sub
REM 'basicstartup' is called once to set your routines up. From then on
REM 'basicprocedure' is called every other time slice.
gomult CommandLine%
END
SUB basicprocedure
REM This sub is where your code goes that runs in the background.
REM Keep in mind that the idea is to run unnoticed while
REM the user is using his machine for other things. Try to keep memory
REM usage as low as you can.
REM This sample just pokes the time into the upper right corner of the screen.
SecondCount% = 0
OldTime$ = TIME$
here:
IF OldTime$ = TIME$ THEN GOTO here2
OldTime$ = TIME$
DEF SEG = &HB800
Count% = 0
FOR i% = 122 TO 136 STEP 2
Count% = Count% + 1
POKE i%, ASC(MID$(TIME$, Count%, 1))
NEXT i%
here2:
SecondCount% = SecondCount% + 1
IF SecondCount% > 20 THEN SecondCount% = 1
a$ = STRING$(20, CHR$(176))
MID$(a$, SecondCount%, 1) = CHR$(219)
Count2% = 0
FOR i% = 272 TO 310 STEP 2
Count2% = Count2% + 1
POKE i%, ASC(MID$(a$, Count2%, 1))
NEXT i%
IF CommandLine% = 0 THEN yield
GOTO here
END SUB
SUB basicprocedure2
REM This Sub is called when you press the hotkey. Background tasks are stopped.
REM You can use this to exit, or to do some configuration, or whatever..
REM Call EXITMULT once, then exit the sub to activate it.
PRINT "I'm removing the program from memory."
exitmult
END SUB
SUB basicstartup
REM In this sub, put any code your routines need to perform only once.
REM It is called before the background task switching begins, but after
REM the kernal is installed. If you made it this far, you can be pretty
REM sure all is ok.
CLS
LOCATE 5, 1
PRINT " This is a rather simple example of making a QB 4.5 program"
PRINT "run in the background. We will just poke a clock into the "
PRINT "upper right hand corner of the screen, and exit to the DOS prompt."
PRINT : PRINT
PRINT " Please press any key to begin..."
WHILE INKEY$ = "": WEND
PRINT "Background tasks installed."
PRINT "All processes now running..."
PRINT "LeftShift/F10 will remove from memory."
LOCATE , , 1
END SUB