home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
PMPRINT.ZIP
/
PMPRINTF.DOC
next >
Wrap
Text File
|
1991-03-20
|
6KB
|
136 lines
PMprintf -- 'printf' support for Presentation Manager programs
==============================================================
Mike Cowlishaw, Feb 1991
* Would you like to use the C standard function 'printf' in your PM
programs for debugging, occasional error messages, etc.?
* Do you have existing subroutines, that use printf, that you'd like to
use in PM programs?
If you answer yes to either of these, you may find the PMprintf tool
useful. PMprintf comprises two parts:
printf.obj -- an object file which you link in with your PM program
just like any other subroutine. This provides the printf service to
that program. You write printf calls in your C program in the usual
way; the printf subroutine buffers the data (on a per-thread basis
in multi-thread programs) and adds each completed line to a message
queue. For example, the following printf call will write a line to
the PMprintf application and sound the Alert (bell):
printf("This seems to work\a\n");
Source (in C) is also provided for the printf function.
pmprintf.exe -- is a PM application which sets up the queue used by
printf and then "catches" and displays incoming printf lines. It is
a kind of 'monitor' or 'virtual console' which will accept lines
from any number of processes that use printf. PMprintf offers a
number of options, including the ability to log the incoming lines
to a file. See below for a short description of the options.
If PMprintf has been started then it will display the incoming lines
from printf calls in other processes. If it has not been started,
then printf calls are ignored (they return 0, not an error).
PMprintf can be started or stopped at any time, and printf calls
will then become active or be ignored as appropriate.
Source for printf (printf.c) is included in the package; this offers
certain customization options (for example, you can cause a prefix to be
added to the start of each line so that different applications can have
unique output lines, or cause lines to be broken at a certain length).
There are also some and usage hints and minor restrictions, documented
in the header of printf.c.
pmprintf.exe
============
pmprintf.exe is a standard PM application that can be started in any
of the usual ways (from a window, from Start Programs, from startup.cmd,
etc.). It presents a standard PM window with an action bar and a list
box. The list box is used for displaying and scrolling the most recent
250 lines received from printf calls in the same or other processes.
The action bar selections are as follows:
File:
Has five sub-items:
Logging Active:
If checked, all incoming lines are written (logged) to the file
(called the LogFile) named by selecting LogFile Name. The LogFile
is opened when logging is activated, and closed when de-activated.
Timestamp LogFile:
If checked, all lines written to the LogFile are prefixed with the
date and time that the line was sent by the printf subroutine (this
could be some time earlier than the time of display by PMprintf,
especially if Pause was used).
LogFile Name...:
Allows alteration of the name of the LogFile. The default name is
'c:\pmprintf.log'. Any previous LogFile in use is closed. If the
new LogFile already exists, printf lines will be appended at the end
of the file. The dialog box for changing the name also offers a
'Logging Active' checkbox, for convenience.
Once changed, the Logfile name is preserved in OS2.INI, and becomes
the default when PMprintf is next started.
Erase LogFile:
Erases ('resets') the current LogFile. No confirmation is
requested.
Exit:
Same as selecting Exit on the action bar.
Options:
Has three sub-items:
Erase Lines:
Discards all previously displayed lines. Use this to clear the
PMprintf screen and recover the storage used for displaying "old"
lines in which you have no further interest.
The 'Esc' key may also be used to clear the PMprintf screen.
Beep on Arrival:
If checked, PMprintf will beep to alert you when a new line arrives
from a printf call.
Self Test:
If checked, PMprintf will call printf itself to display a line on
screen, and then allow selection of lines in the display: each
selection causes a new line to be added. This is used to check that
printf and the queuing mechanism are working.
Pause:
Used to stop new messages scrolling the screen. Selecting Pause will
stop incoming messages; the Pause item is then replaced by a
highlighted Restart item -- no incoming messages will be displayed
until Restart is selected.
Exit:
Closes down PMprintf, after asking for confirmation. (Double click on
the system menu icon at top left for immediate close-down.)
Help:
Refers to this document.
Installation
============
Download the PMPRINTF RAMBIN, in binary. Use LOADRAM2 (often called
simply LOADRAM) to unpack the files. To check it works, "start
pmprintf" and then select the "Self Test" item under "Options". You
should see a line appear in the PMprintf window: this was created by the
'printf' subroutine being called by PMprintf.
Caveats
=======
PMprintf and printf were compiled using the IBM C/2 compiler (1.1). They
were developed under OS/2 1.3 using the 1.3 Toolkit, though seem to run
OK under OS/2 1.2. They have not been fully tested in that environment.
Note that, because printf uses the C Library function sprintf to do its
formatting, you cannot use DosCreateThread to start a thread that uses
printf; you must use _beginthread. Thanks to Sam Detweiler and Bertrand
Denoix for alerting me to this restriction!
History
=======
1.0 7Feb91 Initial Release
1.1 12Feb91 Save/Restore LogFileName in OS2.INI
1.2 16Feb91 Improved printf routine: no restriction on number of
arguments
1.3 19Mar91 Allow Esc key for Clear; restrict number of lines kept