home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_03_03
/
3n03063b
< prev
next >
Wrap
Text File
|
1992-01-15
|
3KB
|
71 lines
/* SPINNER.C */
/* S. Van Dyke, AFAB Ent. */
/* 7918 N. Central */
/* K.C., Mo. 64118 */
/* Spinning cursor for long, quiet applications */
#include <stdio.h>
#include <conio.h> /* if following example 2 */
#define BACKSPACE 8 /* BackSpace character */
void main(void)
{
char spinner[] = {"\\|/-"}; /* '\\' yields '\' */
int spinpos;
int i, nrecs;
clrscr();
printf("Spinning cursor demo program\n");
/* Example 1 */
/* For applications that do not print to the screen */
spinpos = 0; /* reset spinner */
printf("Working %c%c", spinner[spinpos++], BACKSPACE);
spinpos &= 0x03; /* limit to valid characters */
for (i=0; i < 100; ++i)
{ /* Long processing loop */
/* Update spinner */
printf("%c%c", spinner[spinpos++], BACKSPACE);
spinpos &= 0x03; /* limit to valid characters */
/* Whatever operation the loop performs */
delay(100); /* approx 1/10th second delay */
} /* end of main processing loop */
/* Example 2 */
/* For applications that may output to the screen and/or */
/* where the total number of iterations is known */
/* Note: gotoxy() and cprintf() are Turbo C specific */
nrecs = 100; /* determine number iterations to perform */
spinpos = 0; /* reset spinner */
gotoxy(1, 3); /* spinner message position */
cprintf("Processing: %c %-5d ", spinner[spinpos++], nrecs);
spinpos &= 0x03; /* limit to valid characters */
for (i=nrecs; i > 0; --i)
{ /* Long processing loop */
/* Update spinner */
gotoxy(13, 3); /* set to spinner position */
cprintf("%c %-5d ", spinner[spinpos++], nrecs--);
spinpos &= 0x03; /* limit to valid characters */
/* Whatever operation the loop performs */
delay(100); /* approx 1/10th second delay */
} /* end of main processing loop */
gotoxy(11, 3);
cprintf(" complete."); /* overwrites spinner */
}
/* End of file */