Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!pacbell.com!att!cbnewse!cbnewsd!knudsen From: knudsen@cbnewsd.att.com (michael.j.knudsen) Newsgroups: comp.os.os9 Subject: Re: single character read Summary: weird Message-ID: <1990Nov2.234159.9366@cbnewsd.att.com> Date: 2 Nov 90 23:41:59 GMT References: <1728@ruunsa.fys.ruu.nl> Organization: AT&T Bell Laboratories Lines: 30 In article <1728@ruunsa.fys.ruu.nl>, neviatar@ruunsa.fys.ruu.nl (Hadass Eviatar) writes: > The manual tells me to do a > read (1, &buffer, 1); > ^= # of chars > ^= input channel Try using 0, not 1, as the input channel (stdin, not stdout). I hope that helps. > It waits until the second key is struck, and then the function > returns the information on the first keystroke, and puts the > second keystroke in the buffer and waits... This is weird. But in addition to fixing the channel number, the way to do a non-blocking read is to first use a I$GetSt call to find whether there are any characters waiting in OS9's buffer (not the same as YOUR buffer). If not, go do something else. If so, then read one. Tho maybe you aren't asking for a non-blocking read. Anyway, your read() should always return the latest character, so your problem may well be the wrong channel number. > Of course, I tried other buffer-lengths than 1 (even zero!), > but to no avail. Just one byte long will do. Any more is unused. -- "Round and round the while() loop goes; Whether it stops," Turing says, "no one knows."