home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol171 / screen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1984-05-30  |  1.4 KB  |  48 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *  This program takes a Laboratory Microsystems Z80-FORTH screen file  *
  4.  *  and creates a text file from it.  The output format is similar to   *
  5.  *  the format used by Z80-FORTH for listing screens but can be        *
  6.  *  redirected to any device supported on CP/M, or to a disk file which *
  7.  *  can then be edited.  This program can be compiled with the Software *
  8.  *  Toolworks C80 compiler.                        *
  9.  *                                    *
  10.  *  Usage..                                                             *
  11.  *                                    *
  12.  *  SCREEN <file.SCR >output                        *
  13.  *                                    *
  14.  ************************************************************************/
  15.  
  16. #define EOF -1
  17. #define MAXLINE 65  /* max number of characters on line + 1 */
  18. #define LINE_PER_SCR 16  /* number of lines per screen */
  19.  
  20. #include "printf.c"
  21.  
  22. main()
  23. {  int screen=0, linenum, flag;
  24.    char line[MAXLINE];
  25.  
  26.    flag=readline(line); 
  27.    while(flag > 0){
  28.     printf("\nScreen # %d\n\n",screen++);
  29.     for(linenum=0; linenum < LINE_PER_SCR; linenum++){
  30.         printf("%2d %s\n",linenum,line);
  31.         flag=readline(line);
  32.     }
  33.    }
  34. }
  35.  
  36. readline(s)  /* Get a line from screen file, returns 0=EOF; 1=valid line */
  37. char s[];
  38. {  int nblanks,c,i;
  39.    nblanks=0;
  40.    for(i=0; i < MAXLINE-1 && (c=getchar()) != EOF; i++){
  41.     s[i]=c;
  42.     if(c==' ') ++nblanks;
  43.       else nblanks=0;
  44.    }
  45.    if(c==EOF) return(0);
  46.      else { s[MAXLINE-1-nblanks]='\0'; return(1); }
  47.  
  48.