Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:49 13 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: INPUT after INKEY$ problem

Author Message
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 226
Posted: 07:37am 12 Dec 2024
Copy link to clipboard 
Print this post

Hi,

I'm using the CMM2 Firmware Version 5.0702. I have a code to select an item from a menu:



Function menu(items$)
...
' ask user
 Do
   k$ = Inkey$
   Select Case k$

   Case String$(1,128) ' Up
   ...
   End Select

 Loop Until Asc(k$) = 13 ' Return

 ' restore screen & return value
 ...
 menu = sel ' return value = user selection
 font aktfont
 input dummy$  '(!)
End Function


This code uses the Inkey$ function to get a value k$ from keyboard. After processing my "menu-function" returns the selection to the main program.

The problem is that if an INPUT statement in the main program follows this menu-function the main program is not stopping to get the INPUT value. It is as if something else has put in the value into the INPUT variable.

My solution to this problem is that I add a dummy-INPUT-statement within the menu-Function as last statement. See (!) - the funny thing is, that this "input dummy$" will not stop and aks for a value but continue to the end of the function and return to the calling main program. The ASC(dummy$) is 0.

Now my question: Is it a bug or a feature?
-andreas
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 08:49am 12 Dec 2024
Copy link to clipboard 
Print this post

to flush the input buffer
DO : LOOP UNTIL INKEY$ = ""

VK7JH
MMedit
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 226
Posted: 10:56am 12 Dec 2024
Copy link to clipboard 
Print this post

  TassyJim said  to flush the input buffer
DO : LOOP UNTIL INKEY$ = ""


Thank you Jim!

The menu(Items$) function lives in an .inc file for a long time without any issues. Now I write a new program, use the good old menu.inc and discover that the INPUT is not working as expected.
I didn't relate inkey$ function and input command to a common buffer.

-andreas
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025