Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code fix
#14
(11-06-2022, 02:46 PM)mnrvovrfc Wrote: "INPUT$(1)" maybe it's real useful.

"INPUT$(n)" where n > 1, well, watch out.

And "INPUT$(n, filenum)", I'm not even going to comment on.

That's why this is one of the statements I intensely dislike and never used. Sorry, it sucks. There have been many attempts to ditch "INKEY$" and it cannot even be used in a "serious" game project. Imagine having to use "INPUT$()" for any extensive project? Is it even employed in the BASIC portion of the QB64 source code? Probably for the "Press any key to continue" prompt LOL.

I tend to use INPUT$ a ton.  Where I've found it especially useful is when the user needs to make a choice, and I don't need an ENTER keypress for their entry.

PRINT "Which option (from 1 to 9)?"
DO
   a$ = INPUT$(1)
LOOP UNTIL a$ > "0" and a$ <= "9"

There's no need for _LIMIT, _DELAY, or anything else with the process.  INPUT$ pauses program execution until the correct number of keypresses are entered, keeping CPU usage down and not wasting machine resources.

It's also good for passcodes, without showing the text on the screen:

PRINT "Enter your four digit passcode =>";
a$ = INPUT$(4)

As long as pausing program execution isn't an issue, I find INPUT$ to be better to use than INKEY$ any time.  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



Users browsing this thread: 2 Guest(s)