Thanks, guys. Some useful suggestions there.
I don't think I ever used INKEY$ -- am I right in thinking that it takes input straight from the keyboard without requiring a "return" to be pressed?
I will experiment and report back.
Malcolm
Thanks, guys. Some useful suggestions there.
I don't think I ever used INKEY$ -- am I right in thinking that it takes input straight from the keyboard without requiring a "return" to be pressed?
I will experiment and report back.
Malcolm
Yes
@OldMosses: You may want to consider adding _LIMIT 30 in your INKEY$ DO:LOOP. It helps reduce CPU usage a lot. This was never an issue with QB/QB45, which moved a lot slower through loops than QB64 does.
Pete
@OldMoses: I've used a very similar approach for input, in the past.
FUNCTION Limit$ (prompt$, limiter$)
PRINT prompt$;
DO
Limit$ = INPUT$(1)
LOOP UNTIL INSTR(limiter$, Limit$)
PRINT Limit$
END FUNCTION
Then you just call it as needed:
answer$ = Limit$("Are you M)ale or F)emale? ", "MFmf")
answer$ = Limit$("Enter a number from 1 to 5", "12345")
It's s great little way to validate single keypress input. ;)