goc30 Guru Joined: 12/04/2017 Location: FrancePosts: 435
Posted: 02:36pm 23 Sep 2019
your code is good but not the best, bcause on return from your subroutine, you don't know why you come back. You must test inp$ to know, and remenber that timer work all time (and you can use timer on other sub) and for that an loop "do..while" with timer cond is not the more stable coding.
I propose other code, with 2 more var in call: status return who say why you come back, and string var with key receive
SUB conINP(tm,inp$,stat%) ' stat%=0 if sub in work (no timeout and waiting key$) ' stat%=1 if end on time-out ' stat%=2 if end on inkey buffer not empty and inp$=key$ local vtm as integer vtm = TIMER inp$ = "" stat% = 0 etq1: if TIMER - vtm > tm then stat% = 1: exit sUB inp$ = INKEY$ if inp$ <> "" then stat% = 2: exit SUB goto etq1 END SUB