Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF (EN)

68 You must follow the word INPUT with a numeric variable if you are expecting a number and with a string variable if you are expecting a string. As you will have seen from the examples above you usually need to print a question on the screen to tell the person at the keyboard what you are waiting for. In the last example the question was ‘What is your name’. Instead of placing this in a separate PRINT statement you can include the question on the INPUT statement. 20 INPUT "WHAT IS YOUR NAME ", NAME$ 30 PRINT "HELLO ";NAME$;" HOW ARE YOU?" >RUN WHAT IS YOUR NAME ? SUSAN HELLO SUSAN HOW ARE YOU? Notice the punctuation between the question ‘What is your name’ and the string variable NAME$ .

It is a comma. Notice also that the computer printed a question mark after the question when the program was run. It always prints a question mark on an INPUT statement if a comma is used to separate the question from the string variable. If you leave the comma out of the program the computer will leave the question mark out when the program is RUN . 20 INPUT "WHAT IS YOUR NAME " NAME$ 30 PRINT "HELLO ";NAME$;" HOW ARE YOU?" >RUN WHAT IS YOUR NAME STEPHEN ALLEN HELLO STEPHEN ALLEN HOW ARE YOU? The INPUT statement, which we have explored above, requires that the user presses the RETURN key after he or she has entered the reply.

Until the RETURN key is pressed the user can delete errors with the DELETE key or delete the whole entry so far with CTRL U . Several inputs can be requested at one time. If you type 10 INPUT A,B 20 PRINT A,B two numbers will be expected by the computer. They can either be typed in separated by commas, or both can be followed by RETURN . The INPUT statement will ignore leading spaces and anything after a comma unless the reply is inside quotation marks. 10 INPUT A$ 20 PRINT A$ >RUN ?ABC,DEF ABC