2.2 Syntax Rules 2
Using Variables
In the following program, we will start by writing "Hello" to the screen, using the command we learned in the last example.
Print "Hello"
This time though, we won't be
placing it into a Repeating loop. This means that it will only be printed
once onto the users screen.
After this, the user will be confronted with Uncomfortable Silence.
So, In order to move the program along, we will use one of the USCoS's.
What better than the classic "What's your name?" The user
will then respond. When they do, we will need to store their response into
a store of some sort, inside the inside of the PC. We will do this
using the Onboard Memory, which is onboard the PC. If your PC has no
Onboard Memory, you will need to use your initiative, and substitute the
computer's Onboard Memory with a piece of Paper and a Pen, or maybe a Punched
Card. For the purposes of this chapter though, we will only be using the
Onboard Memory. We will cover the usage of Punched Cards in a later
Chapter.
Imagine that inside your computers memory are thousands of little boxes. Each of these boxes can hold a single item, such as a letter or a number. When the user input's their information we will store it in one of these boxes. To do this, we need to Assign the information to one of these boxes. We call these boxes Memory Locations, and since the information in these Memory Locations changes, we refer to them as Variables. To make things easier we will give one of these Memory Locations a name. In our case, the name we name our Memory Location will be Name, since the answer to the question we ask the user will be the user's name. We place the users name into the box named Name, and the computer will keep it there until we need it later on.

A diagram of the computer's Onboard Memory,
showing one of the Boxes has been labelled Name.
However, remember, The computer will only remember the name, so long as we do not end the program at any time. As soon as you end the program, the computer will forget any information in it's box.
Now, since we're working in Blitz, we don't have to worry about having to name each Memory Location before we use it. If we were working in any other language, we probably would have to declare all of our Variables at the begining of the program, but we don't, so don't bother about it. To use a Variable named Name, we will simply use it when we need it.
Name$ = "Greenie"

The box labelled Name now has the word Greenie stored inside it.
Here, we have placed the name "Greenie" into the Variable named Name. The $ sign at the end of the word Name denotes that Name is a box that holds a word, or a phrase, or any other type of data which is not a Number. If we were to want to store a number we would not place a symbol at the end, unless we wanted the number to be a real number. A real number is a number which has a decimal point, and a series of decimal places. If we want to use decimal places, we should use the # symbol to denote a Real Number which uses decimal places, otherwise no symbol denotes an Integer which has no decimal places. To recap.
Number : An integer number with no decimal places. This could hold a persons Age.
Number# : A Real number which has decimal places. This could hold a persons Height.
String$ : A string of letters, numbers, words or phrases. This could hold a persons Name.
We use the Equals sign to show that Name$, the String, should become equal to the word we suggest. In this case "Greenie". In future, we can look at Name$ and it will tell us Greenie. We will do this next using the Print function.Print Name$
This will print everything in the Name$ string out onto the screen. This is really all we need to know for our simple program. We will discuss more about Variables in a later section.