Category : Word Processors
Archive   : VIEWLIST.ZIP
Filename : VIEWLIST.C

 
Output of file : VIEWLIST.C contained in archive : VIEWLIST.ZIP

#include
#include
#include

extern directvideo;

#define FIRSTPART 33
#define MAXLINE 500
/* adjust linelen for best fit */
#define LINELEN 55
void split(char *Text);

void main(void)
{
char Filename[40];
char Line[MAXLINE];
FILE *fp;

directvideo=0;
cprintf("\n\rEnter Filename: ");
gets(Filename);
fp=fopen(Filename,"r");
if(fp==NULL) return;
clrscr();
while(TRUE)
{
if(fgets(Line,FIRSTPART,fp)==NULL) break;
textattr(7);
Line[12]=Line[22]=Line[33]=0;
textattr(15); /* print the header info */
cprintf("%s %s %s\n\r",Line,Line+13,Line+23);
/* stretch it out a bit */
fgets(Line,MAXLINE,fp); /* get remainder of line */

textattr(11); /* now print the text in many lines*/
split(Line);

if(wherey()>19) /* check for pagebreak */
{
textattr(12);
cprintf("\n\rPAUSE");
if(getch()==27) break;
clrscr();
}
}
fclose(fp);
}


void split(char *Text) /* take a line a split it every xx bytes */
{
int count=0;
cputs(" ");
while(*Text) /* keep going till end */
{
while(count==0 && *Text==' ') Text++; /* skip leading spaces*/
putch(*Text);
count++;
if(count>LINELEN && *Text==' ')
{
cputs("\n\r ");
count=0;
}
Text++;
}
cputs("\n\r"); /* new line */
}