# getch - get a character from file fd. # NOTE - RDOS/AOS differences below include ratdef integer function getch (c, fd) integer c, fd include channel if (0 <= fd & fd <= MAXCHNL & channel(fd) ^= ERR) { if (md(fd) ^= READ) { md(fd) = READ; ic(fd) = 1; nc(fd) = 0 } repeat { if (nc(fd) < ic(fd)) { # fill the buffer. nc(fd) = 0 call rdlin (fd, linebuf(1,fd), nc(fd), ier) call chkio (fd, ier) ic(fd) = 1 } if (nc(fd) < ic(fd)) c = EOF # we must have hit eof! else { c = byte(linebuf(1,fd), ic(fd)) & 177k ic(fd) = ic(fd) + 1 # comment out next two lines if AOS, keep if RDOS # if (c == NEWLINE) c = NULL # change NEWLINE to NULL # else if (c == CR) c = NEWLINE # change CR to NEWLINE } } until (c == EOF | c ^= NULL) # get rid of null's } else c = EOF return (c) end