Mail Archives: djgpp/1995/05/04/11:01:18
As other mentioned, putting 2r1 into the environment of GO32= redirects
stderr to stdout, so you can redirect your errors to a file or use |more,
but more has no possibility to get back.
I wrote a simple program called PG similar to PG on UNIX-systems which could
be used instead of more. For example my environment is more than one screen,
so if I've to look at the environment I use SET|PG
As I think this is useful for many of you, I enclose it with this mail
Roland
+---------------------------------------+---------------------------+
I Roland Exler I EMAIL: I
I Universitaet Linz I R DOT Exler AT jk DOT uni-linz DOT ac DOT at I
I Institut fuer Elektrische Messtechnik I I
I Altenbergerstr. 69 I Phone: I
I A-4040 Linz, AUSTRIA I + 43 732 2468 9205 I
+---------------------------------------+---------------------------+
#include<stdio.h>
#include<stdlib.h>
#define LINELEN 100
#define PAGELEN 24
#define MAXLINES 10000
char* (zp[MAXLINES+2]);
int znum;
int topline;
void allout()
{ for (int i=0; i<znum; i++)
{
fprintf(stdout,"%s",zp[i]);
fflush(stdout);
};
};
void outline(int i)
{
if (i<znum)
printf ("%s",zp[i]);
};
void outpage()
{
for (int i=topline; i<topline+PAGELEN; i++)
outline(i);
}
int main()
{
char input[LINELEN+1];
zp[0]="===================== TOP OF FILE =======================\n";
znum=1;
while (fgets(input,LINELEN,stdin) && (znum<MAXLINES))
{
zp[znum]=new char[strlen(input)+1];
if (!zp[znum])
{ fprintf(stderr,"Not enough Memory!\n"); abort(); };
strcpy(zp[znum],input);
// fprintf(stdout,"%li %s",strlen(input),zp[znum]);
znum++;
};
if (znum>=MAXLINES+1)
{ fprintf (stderr,"Too much Lines, first %i Lines shown!\n",MAXLINES);
zp[znum++]="============== CAN'T PROCESS MORE LINES! ================\n";
}
else
zp[znum++]="===================== END OF FILE =======================\n";
topline=0;
outpage();
while (1)
{ printf ("PG: quit Up Dn PgUp PgDn Home End\x0d"); fflush(stdout);
char c=getch();
printf (" \x0d");
switch (c)
{
case 'q': // quit
case 'x': // exit
return 0;
break;
case 71: // home
topline=0;
outpage();
break;
case 79: // end
if ((topline=znum-PAGELEN)<0) topline=0;
outpage();
break;
case 73: // page up
if ((topline-=PAGELEN)<0) topline=0;
outpage();
break;
case 81: // page down
case 32: // space
for (int i=0; (i<PAGELEN) && (topline+PAGELEN)<znum; i++)
{ outline(topline+PAGELEN); topline++; };
break;
case 72: // cursor up
if (topline)
{ topline--; outpage(); };
break;
case 80: // cursor down
case 13: // return
if ((topline+PAGELEN)<znum)
{ outline(topline+PAGELEN);
topline++;
};
break;
/*
case 'g': // go
printf("Enter Line number (TOP is %i of %i): ",topline,znum-2);
scanf("%i\n",&topline);
{ outpage(); };
break;
*/
default:
printf("%i ",c);
};
};
};
- Raw text -