home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!gatech!asuvax!cs.utexas.edu!geraldo.cc.utexas.edu!slcs.slb.com!PJONES@128.58.42.3
- From: pjones@asl.slb.com
- Subject: Passing variable length arguments -twice- ... revisited.
- Message-ID: <1992Dec15.164604.19705@slcs.slb.com>
- Sender: news@slcs.slb.com (News Administrator)
- Nntp-Posting-Host: 129.87.186.2
- Reply-To: pjones@asl.slb.com
- Organization: Schlumberger/Anadrill Sugar Land, TX
- Date: Tue, 15 Dec 92 16:46:04 GMT
- Lines: 68
-
-
-
- This is the same question as before, but with the necessary details. Thanks
- to all who answered with the vprintf() suggestions ... I learned something
- there. The problem with vprintf() is that it prints only in black and white
- ... it ignores the textcolor() and textbackground() settings that I am
- using. So the new questions are:
-
- 1. Can I pass the arguments to cprintf()? The code below does not work
- with cprintf() (I didn't expect it to), but it does work with vprintf().
-
- 2. If the answer to #1 is "No", can I get vprintf() to print in the
- colors already selected?
-
- I am using Borland C++ 3.1, and I have called the help desk. I've also
- looked in FAQ and only vprintf() is mentioned.
-
- If any of you are offended with some flaw in my programming style, I bow
- before you in shame and hope that one day you may forgive my transgressions.
-
- -----
-
- void disp_error(char *msg, ...)
- {
- box error_box( double_line, DOS_COLOR, WARNING_COLOR );
- struct text_info ti;
- int top=10, left=10, bottom=14, right=70;
- char underneath[800];
- va_list ap;
-
- // Handle variable parameters.
- va_start(ap,msg);
-
- // Get the current settings ... to be restored later.
- gettextinfo(&ti);
-
- // Save what will be under the box
- gettext(left, top, right, bottom, underneath);
-
- // Reset screen to full size, and draw the box.
- window(1,1, ti.screenwidth, ti.screenheight);
- error_box.draw(top, bottom, left, right);
-
- // Write 'Error' in the window
- gotoxy(((right-left)>>1)+left-4, top);
- cprintf(" ERROR ");
-
- // Set the window just inside the box borders, then print the message.
- window(left+1, top+1, right-1, bottom-1);
- gotoxy(1,1);
- vprintf(msg, ap); // CAN I USE cprint() SOMEHOW???
-
- // Wait for key press
- window(left, top, right, bottom);
- press_any_key((right-left)/2 - 19, bottom-top+1);
-
- // Restore stuff underneath
- puttext(left, top, right, bottom, underneath);
-
- restore_settings(&ti);
-
- va_end(ap);
- }
- ----
-
- Thanks in advance,
- Phil Jones
- pjones@asl.sinet.slb.com
-