When you are getting INPUT in Commodore BASIC it always adds a question mark at the end of the string you want to show.

Is there a way to suppress the question mark when using the INPUT command?

  • 2
    Before others try it (I did!), it isn't like (say) AppleSoft BASIC where simply using the form INPUT "NAME: ";A$ would suppress the ? with your supplied prompt... it doesn't work.. it still puts the ? there despite supplying the quoted string for a prompt :-/ – bjb Oct 12 '17 at 16:35

Use the INPUT# command.

The INPUT# command is meant for non-interactive I/O on files or devices, i.e. reading from a file on disk, serial port, whatever. Because it is non-interactive, it will not display a prompt anywhere. The keyboard can be opened like any other I/O device, it has device number 0. Knowing that, the implementation is straightforward.

30 INPUT#1,A$



Is there a way to suppress the question mark when using the INPUT command?

No. There are also other problems with using INPUT to get keyboard input. The Commodore PET had a problem where just typing Return would stop the program which probably also exists on the C64. You might be better using the GET command.

  • 3
    The problem with the instant termination when pressing Return does not exist on the C64 – mondlos Oct 12 '17 at 13:35

Back in the day I wrote my own input code using GET. Over time I enhanced it to support various features. You start out with GET A$. Here is a simple one I just threw together:

10 NA$="":PR$="Name:"
20 GOSUB 50000
30 PRINT"Your name is ";
40 END

50000 PRINT PR$;
50010 GET A$:IF A$="" THEN 50010
50030 IF A$=CHR$(20) THEN NA$=LEFT$(NA$,LEN(NA$)-1):? CHR$(157);" ";CHR$(157);GOTO 50010
50040 IF A$>="a" AND A$<="z" THEN 50080
50050 IF A$>="A" AND A$<="Z" THEN 50080
50060 IF A$=" " THEN 50080
50070 GOTO 50010
50080 NA$=NA$+A$:PRINT A$;:GOTO 50010

You'll have to use the question mark in line 50030 to keep the line short enough for the BASIC editor to accept it. BITD I had a blinking cursor implemented.

  • 1
    Doesn't work. My name contains a hyphen! :)) SCNR – Raffzahn Oct 12 '17 at 19:51
  • chr$(20) is ctrl-T; was it used as a backspace instead of ctrl-H (chr$(8)) ? – Leo B. Oct 13 '17 at 2:03
  • 1
    @LeoB.: The INS/DEL key in the upper-right corner of the keyboard generates control-T, which is the normal way of doing a backspace. Cursor-left is character code 147 (decimal). – supercat Oct 13 '17 at 17:12

POKE19,32 just before issuing the INPUT statement.

  • 1
    I like it, and I can guess what it's doing, but a little explanation would be welcome. – hobbs Nov 11 '18 at 3:35
  • Any number other than zero poked into address 19 would work for this. Address 19 contains the current I/O device. When it is other than zero, the operating system supresses the prompt. When using OPEN1,0:INPUT#1 A$:CLOSE1the effect is the same, with a monitor program one can see that address 19 contains a 1 when the INPUT# command is executed. – Peter B. Jan 13 '19 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.