home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
modems
/
modem
/
readnews.lbr
/
READNEWS.CZ
/
READNEWS.C
Wrap
Text File
|
1987-10-31
|
3KB
|
129 lines
/* READNEWS.C
*
* Bob Stephens, March 1987
*/
/* This program opens the file NEWS on drive m: and displays it on
* the screen. The user enters keywords at the prompt which are
* written to an appropriate MEX script file for automatic downloading
* from STARTEXT.
*
*/
/* Configured for EPSON QX-10
* at the end of this file are the screen functions which can be
* changed for other machines.
*/
#include "stdio"
#define LINEBUF 82
main(argc, argv)
int argc;
char *argv[];
{
FILE *in_file, *out_file, *hdr_file;
int c, line, status;
char choice[30], dline[LINEBUF];
/* open the news file to read: */
in_file = fopen("M:NEWS", "r");
if (in_file == NULL) {
printf("M:NEWS could not be opened. ");
exit(0);
}
/* open the header file to copy: */
hdr_file = fopen("A:GETNEWS.HDR", "r");
if (hdr_file == NULL) {
printf("GETNEWS.HDR could not be opened. ");
exit(0);
}
/* open the output file: */
out_file = fopen("A:GETNEWS.MEX","w");
if (out_file == NULL) {
printf("*** Can't open output file ***");
exit(0);
}
/* copy the header over to the output file: */
while ((c = getc(hdr_file)) != EOF)
putc(c, out_file);
/* now begin processing the input file */
/* main loop */
status = '\1';
while (status != NULL) {
clrscrn(); /* clears screen */
line = 0;
while ((line < 20) && (status != NULL)) {
status = fgets(dline, LINEBUF, in_file);
if (status != NULL) {
line++;
fputs(dline, stdout);
}
}
choice[0] = '1';
while (choice[0] != NULL) {
poscurs(22,0); /* position cursor */
clr_eol();
screen_lo();
printf("Enter your choice or CR: ");
screen_hi();
gets(choice);
if (choice[0] != NULL && choice[0] != '\033') {
/* could use a confirmation routine here */
fprintf(out_file, "SENDOUT \"%s\"\n", choice);
}
if (choice[0] == '\033')
goto end;
}
}
end: fprintf(out_file, "SENDOUT \"BYE\"\nWRT\n");
}
screen_addr()
{
bdos(2, 0x1B); /* Console Output ESC */
}
clrscrn()
{
bdos(2, 0x1A); /* Console Output B */
}
clr_eol()
{
screen_addr();
bdos(2, 0x54);
}
clr_eos()
{
screen_addr();
bdos(2, 0x59);
}
screen_hi()
{
screen_addr();
bdos(2, 0x28);
}
screen_lo()
{
screen_addr();
bdos(2, 0x29);
}
poscurs(r,c)
{
screen_addr();
bdos(2, 0x3D);
bdos(2, 32+r);
bdos(2, 32+c);
}