Posted: Sun Jun 19, 2016 6:34 pm Post subject: Inkey with case statements that need to start with 0
Inkey with case statements that need to start with 0
like if it starts with 0 as 1 then it just hangs on 0
and wont go to the next thing
i just cant see a way out of it lol
(BASCOM-AVR version : 2.0.7.8 , Latest : 2.0.7.8 )
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
Posted: Sun Jun 19, 2016 11:47 pm Post subject:
Inkey returns 0 ( ie Binary zero ) when there is no character in the input buffer. So anytime you enter inkey, and there is no character waiting, you will get 0 as response, hence your case statement always goes to that.
If you use buffered serial input, and ischarwaiting, then only go to the inkey statement when ischarwaiting is true ( 1 ), then you will not have this behaviour. And the case where inkey actually returns a binary zero because there is a zero in the buffer is also correctly handled.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum