Settings

The page will reload to apply your changes.
Theme

ASCII Art Font

ASCII Art Menu

Original Usenet message from alt.ascii-art, 21 Mar 1994.
Re: Use this to slow down view of ascii anims (UNIX)

Re: Use this to slow down view of ascii anims (UNIX)

ewh...@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 <filename> [delay]
 *
 */ 

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/time.h>

#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 (ppa...@snakemail.hut.fi)

Original message headers
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: ppa...@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: <PPA...@alpha.hut.fi>
References: <2mjb35$2u...@vixen.cso.uiuc.edu>
Reply-To: ppa...@snakemail.hut.fi
NNTP-Posting-Host: alpha.hut.fi
In-reply-to: ewh...@uxa.cso.uiuc.edu's message of 21 Mar 1994 05:24:53 GMT
About this message. This message was posted publicly to the newsgroup alt.ascii-art in 1994 and is mirrored here unchanged as part of the Historic Archives – only email addresses are masked. The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can. Are you the author? Contact us to get your posts attributed, connected to your artist profile, or removed.

Report this message

Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.

Help classify this post