[Coco] Inkey loops

coco at jechar.ca coco at jechar.ca
Thu Aug 1 13:25:30 EDT 2019


On 2019-08-01 12:21, L. Curtis Boyle wrote:
> Depending on how your routine is to work, if you are literally waiting
> for a key press to exit a loop, then the best is probably to do an
> F$Sleep system call in between inkey reads.
> 
> A bit of example code might be:
> 
> TYPE registers=cc,a,b,dp:BYTE;x,y,u:INTEGER
> DIM regs:registers
> DIM key:STRING[1]
> LOOP
>   RUN inkey(key)
> (* Exit LOOP/ENDLOOP if a key is pressed
> EXITIF key<>”” THEN
> ENDEXIT
> (* F$Sleep call - remainder of our time slice
>   regs.x=1
>   RUN syscall($A,regs)
> ENDLOOP
> 
> F$Sleep with X=1 means to give up the remainder of the time slice for
> our process to the rest of the system (about 1/10th of a second).

  Yes your reply got to list. Have n't tryed it yet though.

> 
> L. Curtis Boyle
> curtisboyle at sasktel.net
> 
> 
> 
>> On Aug 1, 2019, at 9:03 AM, coco at jechar.ca wrote:
>> 
>> All
>> 
>> In a basic09 program can you suggest the best way to make an inkey 
>> loop without too much
>> cpu overhead ie perhaps using a timer function ?
>> 
>> My previous basic09 programs only used command line parameters rather 
>> then interactive input
>> after the program was started.
>> 
>> Charlie
>> 
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>> 


More information about the Coco mailing list