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

247 INPUT to put information into the computer Purpose When a computer program is running there is often a need to get numbers or words from the outside world into the computer so that it can do calculations on these numbers or words. The statement INPUT is used for this purpose. There are a number of options: 100 INPUT X will print a question mark on the screen and wait for the user to type in a number. This is not very ‘friendly’ – often it would be helpful to print a message on the screen before waiting for the user to type his/her reply. This can be done in two ways:

340 PRINT "How old are you"; 350 INPUT AGE or more simply 340 INPUT "How old are you",AGE If you do not wish the computer automatically to print a question mark then omit the comma between the message to be printed out and the variable to be filled in. 340 INPUT "How old are you" AGE Often you may want to input several values one after the other. This can be done by placing the variables after each other, but separated by commas, thus: 560 INPUT "Pick three numbers",X,Y,Z When replying the user separates the values entered either with commas or by pressing the RETURN key after entering each value.

The numbers that are typed in are placed in the appropriate variables – X , Y and Z in the example above. The above examples all required numbers to be supplied by the user. You can INPUT words as well. 250 INPUT "What is your name", NAME$ You can INPUT more than one string at a time if you wish by using 200 INPUT "Town" ,A$,"Country",B$