X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f996b,17f651dadba31122 X-Google-Attributes: gidf996b,public X-Google-ArrivalTime: 1994-03-21 07:37:50 PST Path: gmd.de!xlink.net!howland.reston.ans.net!pipex!sunic!news.funet.fi!nntp.hut.fi!nntp.hut.fi!ppaavila From: ppaavila@snakemail.hut.fi (Petri Paavilainen) Newsgroups: alt.ascii-art Subject: Re: Use this to slow down view of ascii anims (UNIX) Date: 21 Mar 1994 15:37:50 GMT Organization: Helsinki University of Technology, Finland Lines: 80 Distribution: inet Message-ID: References: <2mjb35$2uj@vixen.cso.uiuc.edu> Reply-To: ppaavila@snakemail.hut.fi NNTP-Posting-Host: alpha.hut.fi In-reply-to: ewhodges@uxa.cso.uiuc.edu's message of 21 Mar 1994 05:24:53 GMT ewhodges@uxa.cso.uiuc.edu (Buck Hodges) writes: > Someone once posted a C program to do a similar thing which would of course > work on whatever system had a C compiler. Maybe they'll post it again. Here is `slocat' C-program which was posted here some time ago. I modified it to use usleep-function instead of dummy for loop, so this version shouldn't jam the whole computer. Altough usleep is included in standard libraries of most UNIX systems I found that this is not the case for all systems. To be more compatible I included it in the code. `slocat' requires name of ascii file (animation) as first argument and as second argument (optional) the lenght of delay in milliseconds (default is 400). E.g. `slocat twilight.vt 500' I am not sure wether the system calls are universal enough to work in other environments than UNIX but it might be worth of try. Please report any inconveniences caused. ------ cut here ------- cut here ------ cut here ------ cut here ------ /* * slocat.c * * slocat [delay] * */ #include #include #include #include #include #define DEFAULT_DELAY 400 void usleep (unsigned int); main(int argc,char *argv[]) { FILE *f; unsigned long int delay; char c; if ( !argv[2] || (delay = atoi (argv[2])) <1 ) delay=DEFAULT_DELAY; if (!argv[1]) { puts ("slocat: file not specified"); exit (1); } if (!(f=fopen( argv[1], "r"))) { printf ("slocat: can not open %s\n",argv[1]); exit (2); } while ( !feof(f) ) { putc( getc(f), stdout ); usleep (delay); } fclose(f); } void usleep(unsigned int usec) { struct timeval timeout; if(usec == 0) return; timeout.tv_sec = usec / 1000000; timeout.tv_usec = usec - 1000000 * timeout.tv_sec; select(1, NULL, NULL, NULL, &timeout); } ------ cut here ------- cut here ------ cut here ------ cut here ------ -Petri Paavilainen (ppaavila@snakemail.hut.fi)