#-h- crt.r 1376 asc 08-apr-81 09:30:16 [002,101] #-h- main 732 asc 08-apr-81 09:29:44 [002,101] ##crt - prepare output for CRT DRIVER(crt) integer getarg, ctoi, open, getlin, prtnl integer i, j, tt, nlines, input character buf(MAXLINE) string terml TERMINAL_IN data nlines /22/ data input /NO/ call query("usage: crt [-n] [file] ...") tt = open(terml, READ) if (tt == ERR) call cant(terml) for (i=1; getarg(i,buf,MAXLINE)!=EOF; i=i+1) { 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) DRETURN end #-h- prtnl 520 asc 08-apr-81 09:29:45 [002,101] ## 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 #-h- crt.rof 1152 asc 02-may-81 21:57:03 [002,100] .pl 60 .bp .rm 70 .in 0 .he 'CRT'1/12/79'CRT' .fo ''-#-' .fi NAME .br .in 7 crt - copy files to terminal .sp 1 .in SYNOPSIS .br .in 7 crt [-n] [file] ... .sp 1 .in DESCRIPTION .br .in 7 CRT is similar to 'cat' except that it prints only n lines (default 22) at a time. After each set of lines are printed, crt will wait for instructions from the user. Hitting a carriage-return will cause the next n lines to appear, hitting a 'q' (quit) will cause crt to skip over to the next input file (if any), and hitting an end-of-file character will cause crt to stop immediately. If no files are specified, or if the filename '-' is given, lines will be read from the standard input. The flag -n may be given, where n specifies the number of lines desired at a time. Crt will stop at the end of each file (except the last), as well as after each n lines. .sp 1 .in FILES .br .in 7 .sp 1 .in SEE ALSO .br .in 7 cat .sp 1 .in DIAGNOSTICS .br .in 7 A message is printed if an input file cannot be opened; further processing is terminated. .sp 1 .in AUTHORS .br .in 7 .sp 1 Debbie Scherrer .sp 1 .in BUGS .br .in 7