Microsoft KB Archive/47702
INF:Sending Output from Program to Monochrome (Second) Monitor PSS ID Number: Q47702 Article last modified on 09-10-1991 PSS database name: O_Os2SDK
There is no equivalent method under Presentation Manager (PM) that allows debugging information to be sent to a second monitor/terminal, as can be done using the fprintf() statements under Windows. However, there is a method that can be used that is similar and quite simple.
Printf() statements, which will take advantage of redirection into another utility that actually echoes the output, can be added to a PM application. Normally, the printf() statements would go into the bit bucket. However, if the output is piped into something else that then prints out the output, this produces the desired effect.
After adding the debugging printf() statements that are desired, a windowed command prompt should be opened and the following command should be issued:
PMappname | megrep ^^?
If this command is used, MEGREP (which comes as part of the M editor with the Microsoft C Compiler package) must be made windowable. This can be done by using MARKEXE. Other utilities can be used, as long as the utility echoes input from stdin to stdout in some form, and the utility can be made to run in a window.
Once the application starts, any output that is sent to stdout [such as printf()] gets piped into MEGREP. The question mark (?) means match any character. The second caret (^) means do this only at the beginning of the line. The first caret is used to escape the second caret, because the caret character (^) has special meaning for OS/2’s CMD.EXE.
Debugging statements will now go to one window, while the application runs in another window.
For more information about additional debugging functions for OS/2 versions 1.1 and 1.21, which describes another method that makes use of calls supported by the debugging version of PMDD.SYS, query on the following words:
PMUTILS and UTILS.C
These calls work only for OS/2 version 1.1, and since they are undocumented, they are subject to change and may or may not work with later releases of OS/2.
PMUTILS can be found in the Software/Data Library by searching on the keyword PMUTILS, the Q number of this article, or S12251. PMUTILS was archived using the PKware file-compression utility.
Copyright Microsoft Corporation 1991.