Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shortest useful program
#11
Quote:That can be done in only one line:

Code:
a$ = input$(1)

Toonski, your one-liner works *most* of the time. However:

1) If the user keys more than 1 character, your routine will take the first character, and subsecuent characters will be left in the buffer for a later input$ or inkey$ to read. This is exactly what I don't want. If I asked the user to answer "Y" or "N", I only want to read a one character Y or N for processing. If he hits "NO", my routine would just process the "N" and ignore the "O". However, it detects the "O" and throws it away so it doesn't get read later.

2) My routine uses INKEY$ which permits the user to press extended characters like Home, PageUP, PageDn, Up, Down, Left, Right, etc. Your use of Input$ will not handle these extended characters.

In conclusion, my routine addresses a complete, general purpose solution to the stated specifications, which are"... gets one and only one character from the user, and makes sure that he didn't enter more than one by gobbling up any excess characters." These specifications don't mention reading extended characters, but the routine does not exclude them, assuming they are implicit.
*****
Reply


Messages In This Thread
Shortest useful program - by xhantt - 08-10-2003, 03:02 AM
Shortest useful program - by toonski84 - 08-10-2003, 03:58 AM
Shortest useful program - by Moneo - 08-10-2003, 06:31 AM
Shortest useful program - by toonski84 - 08-10-2003, 08:54 AM
Shortest useful program - by xhantt - 08-10-2003, 10:09 AM
Shortest useful program - by ak00ma - 08-10-2003, 10:30 AM
Shortest useful program - by toonski84 - 08-10-2003, 10:42 AM
Shortest useful program - by xhantt - 08-10-2003, 09:49 PM
Shortest useful program - by ak00ma - 08-10-2003, 10:12 PM
Shortest useful program - by Phydaux - 08-11-2003, 02:08 AM
Shortest useful program - by Moneo - 08-11-2003, 03:22 AM
Shortest useful program - by toonski84 - 08-11-2003, 05:00 AM
Shortest useful program - by oracle - 08-11-2003, 05:10 AM
Shortest useful program - by Moneo - 08-11-2003, 06:25 AM
Shortest useful program - by toonski84 - 08-11-2003, 07:06 AM
Shortest useful program - by xhantt - 08-11-2003, 10:32 PM
Shortest useful program - by Agamemnus - 08-11-2003, 11:41 PM
Shortest useful program - by Moneo - 08-11-2003, 11:46 PM
Shortest useful program - by Moneo - 08-12-2003, 11:22 PM
Shortest useful program - by biostar - 08-16-2003, 01:07 AM
Shortest useful program - by oracle - 08-16-2003, 03:31 AM
Shortest useful program - by Moneo - 08-16-2003, 04:16 AM
Shortest useful program - by oracle - 08-16-2003, 06:45 AM
Shortest useful program - by Moneo - 08-16-2003, 07:46 AM
Shortest useful program - by whitetiger0990 - 08-16-2003, 09:03 AM
Shortest useful program - by Moneo - 08-16-2003, 09:48 AM
Shortest useful program - by ak00ma - 08-16-2003, 12:46 PM
Shortest useful program - by Moneo - 08-16-2003, 11:08 PM
Shortest useful program - by whitetiger0990 - 08-17-2003, 12:53 AM
Shortest useful program - by Moneo - 08-17-2003, 04:29 AM
Shortest useful program - by ak00ma - 08-17-2003, 10:59 AM
Shortest useful program - by oracle - 08-18-2003, 01:41 AM
Shortest useful program - by Moneo - 08-22-2003, 05:24 AM
Shortest useful program - by pr0gger - 08-23-2003, 03:32 AM
Shortest useful program - by whitetiger0990 - 08-23-2003, 03:43 AM
Shortest useful program - by Moneo - 08-23-2003, 04:07 AM
Shortest useful program - by otaku84 - 10-14-2003, 03:40 PM
Shortest useful program - by oracle - 10-15-2003, 12:49 AM
Shortest useful program - by seph - 10-15-2003, 02:49 AM
Shortest useful program - by SCM - 10-15-2003, 07:18 AM
Shortest useful program - by Moneo - 10-15-2003, 09:09 AM
Shortest useful program - by oracle - 10-15-2003, 10:27 AM
Shortest useful program - by Lanzaa - 10-16-2003, 06:25 AM
Shortest useful program - by seph - 10-16-2003, 07:18 AM
Shortest useful program - by oracle - 10-17-2003, 01:45 AM
Shortest useful program - by Dav - 10-17-2003, 04:11 AM
Shortest useful program - by Dav - 10-22-2003, 05:51 AM
Shortest useful program - by seph - 10-22-2003, 07:22 AM
Shortest useful program - by oracle - 10-22-2003, 10:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)