[Coco] Re: [Color Computer] Inkey for Microware C Compiler

KnudsenMJ at aol.com KnudsenMJ at aol.com
Sun Dec 7 22:20:24 EST 2003


In a message dated 12/7/03 8:30:27 AM Eastern Standard Time, 
gene.heskett at verizon.net writes:

> To be fair, what I gave there as an example is blocking if there isn't 
>  a character to read, one really should make use of the _os9 i$getstt 
>  call as mentioned in a previous message this morning to ascertain that 
>  there is indeed a character or more to read, thereby giving you the 
>  opportunity to do something else if the buffer is empty.

Right, Gene, I think he was looking for a way not to block and be able to do 
something else if there was no character present.  Like continue with some 
long drawn out process, with a "hit any key to stop it" option.

>  If you 
>  don't have anything else for it to do, then make sleep calls, thereby 
>  unloading the CPU for other stuff, in a loop that wakes up to see if 
>  anything's been typed while napping.

Yes, this is good programming advice.  The sleep() call in a loop is a great 
tool to keep your program alert but not waste valuable CPU time that other 
procs could be using.  Your code eats no CPU at all while sleeping.

>  >If anyone has played with the old Microsoft C and Borland compilers,
>  >they had a function that was declared in the conio.h header. (I
>  > think Borland still might support the old 'getch ()' function, but
>  > I think Microsoft has long forgot terminal support.) Anyway, 'getch
>  > ()' is more of what I'm looking for.

Yes, I remember using getch() in various PC versions of C.  It's a great 
function, and easily simulated with inkey() or the two steps I outlined yesterday. 
 It's really sad that the Unix standard C library never had it -- just too 
hard to implement, I guess.  

I can still post the exact code if anyone wants to see it.  --Mike K.



More information about the Coco mailing list