Article View: borland.public.cppbuilder.nativeapi
Article #13177Re: Redirecting stdout
From: Bob Gonder
Date: Thu, 23 Oct 2003 16:26
Date: Thu, 23 Oct 2003 16:26
23 lines
1850 bytes
1850 bytes
Denville Longhurst wrote:
>I need to import some legacy code into a new GUI app. The legacy code makes
>considerable use of printf() etc.
>
>How do I redirect stdout so that I can display it in a TMemo or whatever
>(display is not a problem, just grabbing the otherwise lost output). It is
>not really viable to go through the legacy code and change all the printf's.
Could you spawn a console for the legacy code to display on?
Or, you could write your own printf that the app would use instead of
the standard library version.
OTOH, "viable" or not, changing the printf's is the better long-term
solution. You could write a small program that automates the
conversion. Something along the lines of
Change
first of line printf( format,whatever) rest of line
to
first of line {sprintf( printfstring, format, whatever);
GuiPrint(printstring);} rest of line
Not all that hard a project.
Technical Details
Message-ID:
<4hvfpvsg6j432c11aupcv4s8mlcbu63b2a@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f979256$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f5a2ee1e49a6d81b X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-10-23 09:40:52 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Redirecting stdout Date: Thu, 23 Oct 2003 09:26:26 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <4hvfpvsg6j432c11aupcv4s8mlcbu63b2a@4ax.com> References: <3f979256$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.31.164.126 X-Trace: newsgroups.borland.com 1066926386 67.31.164.126 (23 Oct 2003 09:26:26 -0700) Lines: 25 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail