Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code fix
#8
(11-06-2022, 01:11 PM)OldMoses Wrote:
(11-06-2022, 12:59 PM)SMcNeill Wrote: PRINT "Enter a digit"
DO
    K$ = INPUT$(1)
LOOP UNTIL K$ >= "0" AND K$ <= "6"
PRINT K$

Ooooh, INPUT$, I never noticed that one before. A pretty new bauble to play with. Wink

INPUT$ is as old as the language itself -- nothing new or pretty about it!  Honestly though, INPUT$ should get a *LOT* more use than what it does.  What it does is:

1) Wait for a set number of keypresses.  (No need for a sleep, limit, or _delay in any loop -- it does all that itself.)
2) Return that number of keypresses back to you.

INPUT$(1) wants 1 keypress.   INPUT$(3) waits for the user to press 3 keys.  (Or one key 3 times.)

It's simple.  It's very efficient.  Why it's not used more is beyond me.  Wink
Reply


Messages In This Thread
Code fix - by Chris - 11-06-2022, 11:51 AM
RE: Code fix - by OldMoses - 11-06-2022, 12:24 PM
RE: Code fix - by mnrvovrfc - 11-06-2022, 12:50 PM
RE: Code fix - by OldMoses - 11-06-2022, 12:55 PM
RE: Code fix - by SMcNeill - 11-06-2022, 12:59 PM
RE: Code fix - by OldMoses - 11-06-2022, 01:11 PM
RE: Code fix - by SMcNeill - 11-06-2022, 01:20 PM
RE: Code fix - by Chris - 11-06-2022, 01:09 PM
RE: Code fix - by SMcNeill - 11-06-2022, 01:27 PM
RE: Code fix - by Dimster - 11-06-2022, 01:42 PM
RE: Code fix - by SMcNeill - 11-06-2022, 02:09 PM
RE: Code fix - by mnrvovrfc - 11-06-2022, 02:46 PM
RE: Code fix - by SMcNeill - 11-06-2022, 03:19 PM
RE: Code fix - by Dimster - 11-06-2022, 02:53 PM
RE: Code fix - by Pete - 11-06-2022, 06:21 PM
RE: Code fix - by Kernelpanic - 11-06-2022, 09:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  VS Code and Qb64 pe Unseen Machine 6 732 09-03-2025, 09:42 PM
Last Post: grymmjack
  has anyone had ChatGPT write QB64 code yet? madscijr 13 2,963 08-23-2025, 09:15 AM
Last Post: doppler
  liquid code experiment madscijr 3 493 06-20-2025, 07:26 PM
Last Post: madscijr
  [split] Lines of Code bplus 20 3,051 01-25-2025, 05:11 PM
Last Post: Pete
  QB64 GPT Just Rewrote My Code SpriggsySpriggs 17 2,857 05-30-2024, 06:50 PM
Last Post: madscijr

Forum Jump:


Users browsing this thread: