#-h- lcnt.r 1057 asc 07-may-80 15:54:05 #-h- main 283 asc 07-may-80 15:53:59 #--------------------------------------------------------------------- # include symbol definitions # include symbols #--------------------------------------------------------------------- ## main - calling routine for lnct # call initr4 # call lnct # call endr4 # end #-h- lcnts 676 asc 07-may-80 15:53:59 ## lnct - count lines in input file(s) # subroutine lnct subroutine main character getch character c, buf(MAXLINE) integer nl, i, int integer open, getarg nl = 0 for (i=1; getarg(i,buf,MAXLINE)!=EOF; i=i+1) { if (buf(1) == QMARK & buf(2) == EOS) call error ('usage: lcnt [file ...].') else if (buf(1) == MINUS & buf(2) == EOS) int = STDIN else { int = open(buf, READ) if (int == ERR) call cant (buf) } while (getch(c, int) != EOF) if (c == NEWLINE) nl = nl + 1 if (int != STDIN) call close(int) } if (i == 1) while (getch(c,STDIN) != EOF) if (c == NEWLINE) nl = nl + 1 call putdec (nl, 1) call putc (NEWLINE) return end