TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Dominique Curtis
from: Kurt Kuzba
date: 1998-11-16 23:18:10
subject: TC++ Delay() function...

DC>   I have a spinning cursor like what you might see in say,
DC>   BRE (door game) or the like...but in mine, the cursor
DC>   slows down and speeds up with the BBS usage/multitasking...
DC>   and it looks real bad..
DC>                 delay(37);
   what you are doing here is deliberately interjecting a period
   on nonactivity to your code, without regard to system timing.
   Since you are subject to system delays, the code delay may
   append to a system delay and produce an extended delay, which
   is not what you intended. Your timing routine in such cases
   should be based on system time, not on a time-based delay.
   Using the standard clock() function, you can set a point at
   which your routine will execute. If the system delays push
   your time past that point, then it will execute immediately,
   and if not, then you will have your desired delay.
int Spinning_Cursor(char *prompt)
{
   char *spinner = "|/-\";
   clock_t go;
   int spin = 0, keypress;
   output_function_string(prompt);
   do {
      spin %= 4;
      output_function_char(spinner[spin++]);
      go = clock() + CLOCKS_PER_SEC / 2
/*   This calculates the clock value of a half-second
     delay, but not an absolute hard-coded delay. It is
     dynamically responsive to system events. Continuation of
     code execution will be tested against this clock value,
     and will proceed as soon as it is exceeded, whether within
     the loop, or within other code.
*/
      do {
         keypress = input_function();
      }  while(!keypress && go > clock());
      connect_error = test_connect();
   }  while(!keypress && !connect_error);
   return keypress;
}

> ] It's around somewhere. I put it where I wouldn't lose it....

---
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 639/252
SEEN-BY: 670/218
@PATH: 154/750 222 396/1 633/260 635/506 728 633/267

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™.