/* RDNWSKP.C * * Bob Stephens, March 1987 */ /* This program opens the file NEWS on the default drive 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 KAPRO 10 * at the end of this file are the screen functions which can be * changed for other machines. */ #include "stdio" #define LINEBUF 82 main() { 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("NEWS", "r"); if (in_file == NULL) { printf("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() { bdos(2, 0x18); } screen_hi() { screen_addr(); bdos(2, 0x43); bdos(2, 0x31); } screen_lo() { screen_addr(); bdos(2, 0x42); bdos(2, 0x31); } poscurs(r,c) { screen_addr(); bdos(2, 0x3D); bdos(2, 32+r); bdos(2, 32+c); }