TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Larry Snider
from: David Nugent
date: 1994-12-12 15:23:44
subject: C++ CHARACTER FILL

>  textbackground(BLUE);
 >  clrscr();
 >     for (int j=1; j<=25; j++){
 >         for (int i=1; i<=80; i++){
 >             gotoxy(i,j);
 >             cputs("°");
 >             }
 >         }
 > I'm sure just printing 2000 characters would do the same but I would
 > like to make it a generic function.

 > I was using this same technique in a QuickBASIC program and it filled
 > the screen very fast.  With C++ it seems quite slow.  Any suggestions?

Ouch. :-/

The problem is that cputs() is probably updating the screen once for each
character. Borland's OS/2 conio routines aren't very smart in this respect.

If you want to do this, I'd suggest giving Borland's conio library a wide
birth, and instead find PRCP.INF (on many BBSes, it's called 16BITINF or
similar) and take a look at the OS/2 Vio*() calls. Basically, if you buffer
the writes to the screen, you're not executing a bunch of code which
cputs() either does itself, or calls the operating system to do it for each
character.

If you want to see some performance difference without going to too much
trouble, you could use something like:

   char szBuf[81];
   memset(szBuf, '°', 80);
   szBuf[80] = '\0';
   for (int j=1; j<=25; j++){
     gotoxy(0,j);
     cputs(szBuf);
     }

I realise this is only example source, I'd also suggest not hardcoding
lines and columns at 80 x 25. Personally, I find software which does that
annoying as I quite often work in 132x66 and 80x60. Os/2 windows can be
(easily) sized from anything from a couple of lines to 255 lines, and
text-mode software which adapts automaticlaly is so much easier to use on
the desktop.

---

* Origin: Unique Computing, Melbourne, Australia (3:632/348)
SEEN-BY: 12/2442 54/54 620/243 624/50 632/103 301 341 348 633/379 635/503
SEEN-BY: 640/820 690/660 711/409 410 413 430 807 808 809 934 942 949 712/353
SEEN-BY: 712/623 713/888 800/1
@PATH: 632/103 348 711/409 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.