ITYPE\ITYPE.DOC ·
DOC ·
1.1 KB ·
1989-12-05 ·
from PersonalComputing_Feb-1989
We needed a file typer which would pause every screenful
without the need for MORE to be present. Having put it
on the disc to show the text files, we thought we might
as well document it.
Just use:
ITYPE filename
and you'll be prompted to press a key after every
screen of text.
Here's the source code:
/*
File typer - a screenfull at a time without
the need for MORE, by Barry Wood
Returns ERRORLEVEL=1 if wrong number of arguments
2 if couldn't open file
*/
#include <stdio.h>
#define NULL 0
#define WRONGARG 1
#define NOFILE 2
main(argc,argv)
int argc;
char *argv[];
{
FILE *fp;
int lcount;
int c;
if(argc != 2)
{
puts("\n\nUse ITYPE <filename>\n\n");
exit(WRONGARG);
}
if( ( fp=fopen(argv[1],"r") ) == NULL )
{
puts("\n\nCan't open the file!\n\n");
exit(NOFILE);
}
lcount=1;
while( (c=getc(fp)) != EOF )
{
if (c == '\n')
{
if (lcount++ == 20)
{
puts("\n\nPress a key ...");
getch();
lcount=1;
}
}
putchar(c);
}
putchar('\n');
fclose(fp);
}