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$



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 ";NA$
40 END

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

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

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

Create your own custom input routine. The following one allows the input of letters A-Z and numbers 0-9, although it could be farther modified to limit the number of characters entered or to allow the punctuation characters. The input string is is stored in W$

I am using VICE to write this program, so the underline character in lines 20, 110, and 310 are achieved by pressing '[Shift] R'.

5 print
10 w$=""
20 print "_";
30 get a$:if a$="" then 30
40 a=asc(a$)
50 if a=13 then 200:rem return
60 if a=32 then 110:rem space
70 if a=20 then 300:rem backspace
100 if <48 or a>57 and a<65 or a>90 then 30
110 print chr$(20);a$;"_";
115 w$=w$+a$
120 goto 30
200 rem handle return
210 print chr$(20)
215 if w$="" then print:print"you typed nothing!":end
220 print:print"you typed: ";:print w$
230 end
300 rem handle backspace
305 if len(w$)=0 then 30
310 print chr$(20);chr$(20);"_";
320 w$=left$(w$,len(w$)-1)
330 goto 30
10 POKE 19,1   
20 INPUT "ENTER NAME : ";A$   
30 POKE 19,0   

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.