ZX SPECTRUM Introduction
 4. Some simple commandsThe computer memory can be used to store all sorts of things. We have seen, so far, that the PRINT command allows us to show letters, numbers and the results of calculations using both letters and numbers, on the screen.If we want to tell the computer to remember a number, or a string of letters, then we have to allocate some of the memory for that use.Most pocket calculators have a key called 'memory' which is used for remembering numbers for later. Your computer can do much better than that: it can have as many of these imaginary boxes In it as you like and you write a name on each one.As an example, suppose you want to remember your age! The LET command is used (LET is the keyword on the L key): let's say it is 34LET age=34What happens when the LET command is used, is that a certain section of memory is designated 'age' and the number 34 is stored in it. To get this stored information out typePRINT ageand back comes the number 34. It is very easy to change the contents of the 'box' called 'age', Type:LET age=56then type:PRINT ageand 56 should appear on the screen. 'age' is an example of a variable so called because its value may vary. It is possible to combine printing a message direct to the screen, and the value of a variable. TypePRINT "Your age is   ";ageHowever the computer is a lot more useful than just remembering numbers with names attached to them. It can also remember strings of  letters. To differentiate between number variables and string variables - as they are called - the dollar symbol - \$ - is used at the end of the variable name.For example: if we wanted to save the string of letters"Your age is"we could call ita\$(string variable names can only have a single letter, other than the \$, in them). So typeLET a\$="Your age is  "If you now keyPRINT a\$back comes the string of letters on the screen.If the computer hasn't been turned off since the start of this chapter typePRINT a\$;ageand see what happens.There are other ways of getting information into the computer's memory without using the LET command.For example the INPUT command, in its simplest form tells the computer that some information is expected from the keyboard. Instead of typing LET etc. everytime, you can keyINPUT ageOnce the ENTER key has been pressed a flashing L cursor will appear on the screen. This means that the computer wants some information from you. So type your age and then press the ENTER key. Although nothing seems to have happened the variable has now been given the value you typed in. TypingPRINT ageshould prove this.Let's combine all this together into a series of commands. TypeLET b\$="What is your age?"LET a\$="Your age is  "INPUT (b\$);age: PRINT a\$;ageNote that the last line consists of two commands separated by a colon.INPUT (b\$);ageis another way of enteringINPUT "What is your age?";age
 [C] [1] [2] [3] [4] [5] [6] [7] [8] [9]