Category : Pascal Source Code
Archive   : TPTSR.ZIP
Filename : TSR.DOC

 
Output of file : TSR.DOC contained in archive : TPTSR.ZIP

The TSR unit will take your Turbo Pascal 5.5 application and
make it a TSR. TSR stands for Terminated and Stay Resident.
SideKick and SuperKey are two examples of TSR's.

Compile and run tsr.dem. It is a simple calendar TSR.
I coded it using tsr.skl for the skeleton code. Tsr.skl
is fully commented to show you how to make your own TSR.
You may want to compare tsr.dem with tsr.skl. Tsr.int
contains the interface section of tsr.pas.

Tsr.pas declares the MakeTSR() procedure. One call to this
procedure is all it takes to make your application a TSR.


type

TSRproc = procedure;
TSRCommProc = procedure(optCh : char;
argSeg, argOfs : word);

procedure MakeTSR(PopupOptions, PopupID : string;
HotKeyCode, HotShift : byte;
StartUp, Popup, Wrapup : TSRproc;
OptionComm : TSRCommProc);


The first parameter, "PopupOptions", allows you to specify
command line switches and/or arguments for your application.
See cmdln.doc for details on specifying command line switches
and arguments.

The second parameter, "PopupID", is the name you give your
TSR in memory. When your TSR is already resident and you
invoke it again at the DOS command line, perhaps to pass
arguments, the new copy of your TSR looks for an installed
copy under this name. If it finds it in memory already it
will not install itself again.

The third and fourth parameters, "HotKeyCode" and "HotShift",
specify the hotkey that will cause your TSR to popup. Run
hotkey.exe to get these values for the hotkey of your choice.

The rest of the parameters, "Startup", "Popup", "Wrapup", and
"OptionComm" are procedure types that provide hooks to the TSR
unit. The TSR unit calls "Startup" only when installing itself
in memory. It calls "Popup" whenever the hotkey is pressed.
It calls "Wrapup" when removing itself from memory and "OptionComm"
whenever a second copy of your TSR is invoked with command line
switches and/or arguments. Tsr.skl provides further documentation
on what these procedures should do using a "cookbook" approach.



Two variables are also defined in tsr.pas:


const

TSRcolor : boolean = true;
{ Popups can use this to determine color/mono modes. }

var
TSRandPopupOptions: string;
{ Popups can use this with CmdLnParams object }


TSRcolor is set to false if the command switch "-m" for monochrome
is given. Your application should test "TSRcolor" to determine
whether to popup with color or monochrome attributes. Users of
your TSR might not have color capabilities and will greatly
appreciate this feature.

TSRandPopupOptions is the option specification string containing
both the TSR unit options and any additional options you may
have passed to MakeTSR(). This string is used to initialize the
CmdLnParams object if used in your application. See tsr.skl for
a example of how to use this. CmdLn.doc will instruct you on
using the CmdLnParams object. You don't have to use this it is
provided for your convenience only.


The following command line option switches are processed by the
TSR unit (tsr below represent your application's exe filename):


tsr -r to remove the TSR from memory,
tsr -d to deactivate the TSR in memory,
tsr -a to activate TSR in memory,
tsr -m to force monochrome display,
tsr -c to force color display,
tsr -kcode code is scan code of hotkey,
tsr -sshift shift is shift state of hotkey,
tsr -p to popup TSR.


Run hotkey.exe to determine scan code and shift state values.
The hot key can only be redefined by your users when they are
first loading your TSR and can not be changed once your TSR
is resident in memory!

It may seem strange to you a first to have the "-p" switch.
Suppose you have a Paradox application with a script that wants
to popup a HyperText Help TSR with parameters. Let's say your
TSR application accepts an optional file name and hyperlink
topic. Then the script could issue the exec call:

tsr -p -ffilename hypertopic

Both -ffilename hypertopic would be passed to the already
resident TSR via the OptionComm() procedure.


Go ahead and make one your applications a TSR using the TSR unit.
You will notice that you can popup the TSR only 3 times. That's
because you have a shareware version. Upon registering you will
receive the source code and with the cripple flag reset.



This TSR shareware contains the following files:

tsr.doc
tsr.dem
tsr.skl
tsr.int
tsr.tpu

cmdln.doc
cmdln.dem
cmdln.int
cmdln.tpu

crtplus.tpu

calendar.pas

hotkey.exe


Shareware means try before you buy. If you find this unit
useful and are using it in your applications then your are
required to register it!


The registration fee is $20 payable to:


PSW / Power SoftWare
P.O. Box 10072
McLean, VA. 22102 8072


Upon registration you will be sent the source code for
tsr.pas and cmdln.pas on a 5.25" DOS formatted diskette and
be entitled to receive 15 minutes free telephone (703 759-3838)
consultation on the use of tsr.pas and cmdln.pas.


Check your favorite BBS for other shareware tools for TP 5.5
from PSW:


omouse $7 mouse object, primitive paint demo
graphtxt $7 text file device driver for graphic
modes, any font, any justification.
tpflex $20 flexlist object, 100+ page manual
generic stack-queue-list-array
tppan $7 panscroller object, generic pan-scroll
for editors, pick lists, spreadsheets,
etc.
crtplus $20 keyboard, cursor, and popup window
enhancements to crt unit, 100+ page
manual


Thanks for supporting the shareware concept! John