home *** CD-ROM | disk | FTP | other *** search
- (*
- This small program demonstrates how to combine OPREPLAY and OPSWAP to create
- a swappable TSR that can play macros for an underlying application. One
- critical point to note is that the TSR's main unit -- REPLMAIN in this
- example -- CANNOT use OPREPLAY in its USES statement. Doing so causes
- OPREPLAY to link into memory so that it is swapped OUT when the TSR pops
- down. As a result, the interrupt 16h handler would be overwritten by the
- underlying application and a crash would occur.
-
- Procedure pointers are used to avoid this problem. Note how the main block of
- TESTREPL assigns the addresses of the needed routines in OPREPLAY to the
- procedure variables in the interface section of REPLMAIN. In this way,
- routines in REPLMAIN can call those OPREPLAY routines without needing to use
- the unit directly. If your program needs access to more routines from
- OPREPLAY, just declare more procedure variables in REPLMAIN and initialize
- them from the main block of TESTREPL.
-
- Also make special note of the steps required to unload such a TSR from
- memory.
-
- There are a few other tricky things in this demonstration program. If you use
- it as a starting point for a similar TSR, you won't need to worry about all
- these details.
-
- TurboPower Software
- Written 3/8/90
- Updated 5/22/90
- edit REPLMAIN to allow unloading when in non-swapping mode
- *)
-
- {$R-,S-,F-,A-}
- {$M 2048,0,655360}
-
- program TestRepl;
-
- uses
- Dos,
- ReplMain,
- OpSwap,
- OpReplay;
-
- begin
- {Save int 16 vector and install OPREPLAY's}
- GetIntVec($16, SaveInt16);
- SetIntVec($16, @OpReplay.Int16);
-
- {Initialize procedure variables in REPLMAIN}
- @CallStartMacro := @OpReplay.StartMacro;
- CallStringToScrapMacro := OpReplay.StringToScrapMacro;
-
- {Use the 127 character scrap macro for storage, and let REPLMAIN know it}
- InitScrapMacroPtr;
- MacPtr := OpReplay.ScrapMacroPtr;
-
- {Go resident}
- InitializeTest;
- end.