#-h- crt.r 2046 asc 07-may-80 15:11:11 #-h- main 568 asc 07-may-80 15:11:03 #--------------------------------------------------------------------- # include symbol definitions # include symbols #--------------------------------------------------------------------- ## crt -- main program #BKY subroutine driver # call initr4 # call crt # call endr4 # end #BKY #assembly code main program (used to avoid loading fortran I/O) #BKY % #BKY ident main #BKY entry main #BKY vfd 42/0lmain,18/main #BKY ext driver #BKY rj uzero00 #BKY rj driver #BKY end main #BKY% #-h- crts 811 asc 07-may-80 15:11:04 ##crt - prepare output for CRT # subroutine crt subroutine main integer getarg, ctoi, open, getlin, prtnl integer i, j, tt, nlines, input character buf(MAXLINE), terml(FILENAMESIZE) data nlines /22/ data input /NO/ call termin(terml) tt = open(terml, READ) if (tt == ERR) call cant(terml) for (i=1; getarg(i,buf,MAXLINE)!=EOF; i=i+1) { if (buf(1) == QMARK & buf(2) == EOS) call error ('usage: crt [-n] [file ].') else if (buf(1) == MINUS & buf(2) == EOS) int = STDIN else if (buf(1) == MINUS) { j = 2 nlines = max(ctoi(buf,j), 1) next } else { int = open(buf,READ) if (int == ERR) call cant(buf) } input = YES if (prtnl(int, nlines, tt) == EOF) break if (int != STDIN) call close(int) } if (input == NO) call prtnl(STDIN, nlines, tt) return end #-h- prtnl 520 asc 07-may-80 15:11:05 ## prtnl - print nl lines at a time from file int integer function prtnl(int, nl, tt) integer int, nl, tt, prompt integer getlin character buf(MAXLINE) data prompt /NO/ prtnl = OK repeat { if (prompt == YES) { prtnl = getlin(buf,tt) if (prtnl == EOF) { prompt = NO return } if (buf(1) == LETQ | buf(1) == BIGQ) { prompt = NO return } } for (j=1; j<=nl; j=j+1) { prompt = YES if (getlin(buf, int) == EOF) return call putlin(buf, STDOUT) } } return end