home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / modems / modem / readnews.lbr / RDNWSKP.CZ / RDNWSKP.C
Text File  |  1987-10-31  |  3KB  |  123 lines

  1.  
  2. /*  RDNWSKP.C
  3. *   
  4.  *  Bob Stephens, March 1987
  5. */ 
  6. /*  This program opens the file NEWS on the default drive and displays 
  7. *   it on the screen.  The user enters keywords at the prompt which are
  8.  *  written to an appropriate MEX script file for automatic downloading
  9. *   from STARTEXT.
  10.  *
  11. */
  12. /*  Configured for KAPRO 10
  13. *   at the end of this file are the screen functions which can be 
  14.  *  changed for other machines.
  15. */
  16.  
  17. #include "stdio"
  18. #define LINEBUF 82
  19.  
  20. main()
  21. {
  22.     FILE  *in_file, *out_file, *hdr_file;
  23.     int   c, line, status;
  24.     char choice[30], dline[LINEBUF];
  25.     
  26. /* open the news file to read: */
  27.  
  28.     in_file = fopen("NEWS", "r");
  29.  
  30.     if (in_file == NULL) {
  31.       printf("NEWS could not be opened. ");
  32.         exit(0);
  33.      }
  34.  
  35. /* open the header file to copy: */
  36.  
  37.      hdr_file = fopen("A:GETNEWS.HDR", "r");
  38.  
  39.      if (hdr_file == NULL) {
  40.        printf("GETNEWS.HDR could not be opened. ");
  41.           exit(0);
  42.      }
  43.   
  44. /* open the output file: */
  45.  
  46.      out_file = fopen("A:GETNEWS.MEX","w");
  47.     if (out_file == NULL) {
  48.         printf("*** Can't open output file ***");
  49.         exit(0);
  50.     }
  51.  
  52. /* copy the header over to the output file: */
  53.  
  54.      while ((c = getc(hdr_file)) != EOF)
  55.         putc(c, out_file);
  56.  
  57. /* now begin processing the input file */
  58.   
  59.     /* main loop */
  60.  
  61.      status = '\1';
  62.   while (status != NULL) {
  63.  
  64.      clrscrn();  /* clears screen */
  65.      line = 0;
  66.      while ((line < 20) && (status != NULL)) {
  67.         status = fgets(dline, LINEBUF, in_file);
  68.         if (status != NULL) {
  69.            line++;
  70.            fputs(dline, stdout);
  71.         }
  72.      }
  73.      choice[0] = '1';
  74.      while (choice[0] != NULL) {
  75.       poscurs(22,0);  /* position cursor */
  76.       clr_eol();
  77.       screen_lo();
  78.       printf("Enter your choice or CR: ");
  79.       screen_hi();
  80.       gets(choice);
  81.       if (choice[0] != NULL && choice[0] != '\033') {
  82.           /* could use a confirmation routine here */
  83.         fprintf(out_file, "SENDOUT \"%s\"\n", choice);
  84.       }  
  85.       if (choice[0] == '\033') 
  86.         goto end;
  87.      }
  88.    }
  89.    end: fprintf(out_file, "SENDOUT \"BYE\"\nWRT\n");
  90. }
  91. screen_addr()
  92.     {
  93.         bdos(2, 0x1B);  /* Console Output ESC */
  94.     }
  95. clrscrn()
  96.     {
  97.         bdos(2, 0x1A);  /*  Console Output B  */
  98.     }
  99. clr_eol()
  100.     {
  101.         bdos(2, 0x18);
  102.     }
  103. screen_hi()
  104.     {
  105.         screen_addr();
  106.        bdos(2, 0x43);
  107.        bdos(2, 0x31);
  108.     }
  109. screen_lo()
  110.     {
  111.         screen_addr();
  112.         bdos(2, 0x42);
  113.         bdos(2, 0x31); 
  114.     }
  115. poscurs(r,c)
  116.     {
  117.         screen_addr();
  118.         bdos(2, 0x3D);
  119.         bdos(2, 32+r);
  120.         bdos(2, 32+c);
  121.     }
  122.  
  123.