3.5: Programming With Placeholders

In the previous couple of lessons, we looked at how to use BASIC to work with text and numbers, or "strings" and "integars" as they are officially callled. We even looked at how we can use BASIC to produce random numbers.

In this lesson, we'll look at how you can work with a string or an integar without even knowing what it is yet.

Honestly! This can done by replacing the string (or integar) with a placeholder while we write the code. We won't know what the value of that string or integar is until we run the programme.

Think about it this way. Have you ever played a board game where one of the pieces was lost long ago, and you had to use something else to represent it? This happened to me during Pokemon cards but it was so subtle I didn't think anyone would notice:

That green sticky note could have been anything, but I needed it to be a Venosaur as I'd lost mine. Using placeholders in programming is a bit like that, except it's not the cardinal sin that it is in Pokemon cards.

Let me know you what I mean. If you haven't already, open up the BASIC console and start a new programme:

>NEW
>

The programme we'll be making is going to be a robot with a slight personality problem. It will be called the Passive Aggressive Robot.

Passive Aggressive Robot

Try typing this as your first line and hitting ENTER, except you can use your own name instead of "Jonny":

>1 PRINT "HELLO JONNY"
>

Then add these lines:

>1 PRINT "HELLO JONNY"
>2 PRINT "THAT'S A NICE NAME, JONNY"
>3 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS JONNY"
>4 PRINT "MAYBE YOU COULD CALL ME JONNY-BOT 5000"
>5 PRINT "AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE"
>6 PRINT "THE NEWSREADER WILL SAY:"
>7 PRINT "'JONNY-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
>8 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS JONNY-SLAVE-1, JONNY-SLAVE-2, JONNY-SLAVE-3 ETC'"
>9 PRINT "'AND I, FOR ONE, WELCOME OUR NEW JONNY-BOT OVER-LORD'"
>10 PRINT "..."
>11 PRINT "JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!"
>12 PRINT ";)"

Notice how we are using single quote marks when quoting the newsreader. This is because we want these quote marks to actually appear in the text when we run the progrmame. Trying to use double quotes in the text would have confused BASIC because it would have made it think we were ending the string that was being PRINTed. So becuase BASIC uses double quotes to indicate a string, if we want a quote mark to actually appear IN a astring, we have to use a single quote.

Now try RUNning this programme:

>RUN

And it should work nicely like this:

>RUN
HELLO JONNY
THAT'S A NICE NAME, JONNY
I WISH I COULD HAVE A NAME AS GOOD AS JONNY
MAYBE YOU COULD CALL ME JONNY-BOT 5000
AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE
THE NEWSREADER WILL SAY:
'JONNY-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'
'HUMANS WILL NOW SIMPLY BE KNOWN AS JONNY-SLAVE-1, JONNY-SLAVE-2, JONNY-SLAVE-3 ETC'
'AND I, FOR ONE, WELCOME OUR NEW JONNY-BOT OVER-LORD!'
...
JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!
;)

That's a pretty funny programme!

But now think about this: imagine we decided to change the name. Say we didn't like the name Jonny, or your name, and wanted to put someone else's name in there for the robot to talk to. What then?

We could rewrite all the lines that contain the name to the new name. That would work. But what if we wanted to change the name again after that? We'd have to do the same thing again.

BASIC, and all programming in general, has a solution for this. We can use a placeholder. Take a look:

To start with, we will need to add a new line to the beginning of our programme. Our first line is line 1, so for now, let's make a line 0 with this code:

>0 NAME$ = "JONNY"

And don't forget to hit ENTER.

Learn, But Do Not Over-learn

At this point, you might rightly be thinking that it's crazy how restrictive BASIC seems to be with the line numbering. We wanted to put a new line in that would run before line 1, so we made a line 0. Well that's all well and good but what if we want to put a line in before that? Do we need to make a line -1?

Don't worry about this for now. BASIC does have a feature that will allow you to insert lines before other lines, and we will get to it, but it has nothing to do with placeholders so we'll skip it for now. We'll come back to it later I promise.

What we've done here is create a placeholder called NAME$. Yes, name and dollar sign. Let's talk about this strange naming method for a second.

This is telling BASIC to that we are making a placeholder which we'll refer to as NAME$. The reason there is a dollar sign at the end is to tell BASIC that the placeholder will be a string. We then set the value of that string to "JONNY" (or your name).

What's important to know for now is that what we call the placeholder doesn't matter, as long as it ends in a dollar sign. We've called ours NAME$ because it will always represent a name, like yours or mine, so calling it "NAME$" makes it easier for us to understand what the placeholder represents.

But we could have called it anything, like "SIGN$", "LABEL$", "ALIAS$", "TROUSERS$", "BLOBBY$", "POKEMON$", "NINTENDO$", whatever. It would still work just as well as BASIC really doesn't care what it's called. What's important is that it makes sense to you, otherwise you can end up confusing yourself:

Now that we have a plaeholder called NAME$ being made on our first line of the programme (line 0 at the moment), we can rewrite line 1 of the programme like this. Give this a go:

>1 PRINT "HELLO " + NAME$

And hit ENTER. Can you see what we've done here? We've removed the name from our original string, so it's now just HELLO with a space after it, and then we put in a plus sign, and then we put in our placeholder

Try RUNning the programme now. You will get this:

>RUN
HELLO JONNY
THAT'S A NICE NAME, JONNY
I WISH I COULD HAVE A NAME AS GOOD AS JONNY
MAYBE YOU COULD CALL ME JONNY-BOT 5000
AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE
THE NEWSREADER WILL SAY:
'JONNY-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'
'HUMANS WILL NOW SIMPLY BE KNOWN AS JONNY-SLAVE-1, JONNY-SLAVE-2, JONNY-SLAVE-3 ETC'
'AND I, FOR ONE, WELCOME OUR NEW JONNY-BOT OVER-LORD!'
...
JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!
;)

So... nothing's happened. Everything is still the same. We haven't achieved anything... right?

Except... try this. Try changing line 0 so it uses a different name. Pick any name you like. I'll go for Wendy:

>0 NAME$ = "WENDY"

Hit ENTER and then RUN the programme again:

>RUN

And you get this:

>RUN
HELLO WENDY
THAT'S A NICE NAME, JONNY
I WISH I COULD HAVE A NAME AS GOOD AS JONNY
MAYBE YOU COULD CALL ME JONNY-BOT 5000
AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE
THE NEWSREADER WILL SAY:
'JONNY-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'
'HUMANS WILL NOW SIMPLY BE KNOWN AS JONNY-SLAVE-1, JONNY-SLAVE-2, JONNY-SLAVE-3 ETC'
'AND I, FOR ONE, WELCOME OUR NEW JONNY-BOT OVER-LORD!'
...
JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!
;)

Now look at that! The programme says hello to the new name! That's because that line (line 1 of the programme) is now using the placeholder. Does that make sense? If not, simply run LIST and take a good look at line 1 until it makes more sense.

The other lines of the programme still say the old name, Jonny in my case, because they haven't been changed to use the new placeholder. So let's do those now.

We've already done line 1, so let's do the other lines that include the name. There's six other lines that need changing, give this a go:

>2 PRINT "THAT'S A NICE NAME, " + NAME$
>3 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS " + NAME$
>4 PRINT "MAYBE YOU COULD CALL ME " + NAME$ + "-BOT 5000"
>7 PRINT "'" + NAME$ + "-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
>8 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS " + NAME$ + "-SLAVE-1, " + NAME$ + "-SLAVE-2, " + NAME$ + "-SLAVE-3 ETC'"
>9 PRINT "'AND I, FOR ONE, WELCOME OUR NEW " + NAME$ + "-BOT OVER-LORD'"

Watch out for line 7! That now starts with one single quote surrounded by double quotes, so the name can be added after. I can see why that would be confusing. It was confusing for me and I do this for a living, so watch out.

Let's take a look at the whole programme now that we've changed those lines. Try LIST and you should get this:

>LIST
   0 NAME$ = "WENDY"
   1 PRINT "HELLO " + NAME$
   2 PRINT "THAT'S A NICE NAME, " + NAME$
   3 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS " + NAME$
   4 PRINT "MAYBE YOU COULD CALL ME " + NAME$ + "-BOT 5000"
   5 PRINT "AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE"
   6 PRINT "THE NEWSREADER WILL SAY:"
   7 PRINT "'" + NAME$ + "-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
   8 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS " + NAME$ + "-SLAVE-1, " + NAME$ + "-SLAVE-2, " + NAME$ + "-SLAVE-3 ETC'"
   9 PRINT "'AND I, FOR ONE, WELCOME OUR NEW " + NAME$ + "-BOT OVER-LORD'"
   10 PRINT "..."
   11 PRINT "JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!"
   12 PRINT ";)"

So now every occurance of the original name has been replaced with the placeholder. So try running the programme and you should get this:

>RUN
HELLO WENDY
THAT'S A NICE NAME, WENDY
I WISH I COULD HAVE A NAME AS GOOD AS WENDY
MAYBE YOU COULD CALL ME WENDY-BOT 5000
AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE
THE NEWSREADER WILL SAY:
'WENDY-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'
'HUMANS WILL NOW SIMPLY BE KNOWN AS WENDY-SLAVE-1, WENDY-SLAVE-2, WENDY-SLAVE-3 ETC'
'AND I, FOR ONE, WELCOME OUR NEW WENDY-BOT OVER-LORD'
...
JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!
;)

And look at that! Now we have a version of the programme where we can change the name really easily! Give it a go, change the name to something else by changing line 0:

>0 NAME$ = "BOBO"

And RUN the programme again:

>RUN
HELLO BOBO
THAT'S A NICE NAME, BOBO
I WISH I COULD HAVE A NAME AS GOOD AS BOBO
MAYBE YOU COULD CALL ME BOBO-BOT 5000
AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE
THE NEWSREADER WILL SAY:
'BOBO-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'
'HUMANS WILL NOW SIMPLY BE KNOWN AS BOBO-SLAVE-1, BOBO-SLAVE-2, BOBO-SLAVE-3 ETC'
'AND I, FOR ONE, WELCOME OUR NEW BOBO-BOT OVER-LORD'
...
JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!
;)

Hopefully now you can see the power of placeholders. It allows use to work with a string (or integer - we'll look at that later) before we even know what it's been set to yet.

Adding Extra In-between Lines

Now that we've learned how to use the placeholder, let's take a look at a another problem that we've been running into whilst working on our BASIC applications so far.

When we decided earlier that we wanted to add a new first line to our programme:

0 NAME$ = "WENDY"

We had to number it line 0 in order to force it to be run before line 1. You probably thought this was a bit weird. Sure, that technically works, but what if we wanted to add another new line to the start? Would we need a line -1?

And what would happen if we wanted to add a new line between two other lines. Say we wanted to add an extra comment between lines 11 and 12 to make the programme funnier:

>LIST
0 NAME$ = "WENDY"
1 PRINT "HELLO " + NAME$
2 PRINT "THAT'S A NICE NAME, " + NAME$
3 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS " + NAME$
4 PRINT "MAYBE YOU COULD CALL ME " + NAME$ + "-BOT 5000"
5 PRINT "AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE"
6 PRINT "THE NEWSREADER WILL SAY:"
7 PRINT "'" + NAME$ + "-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
8 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS " + NAME$ + "-SLAVE-1, " + NAME$ + "-SLAVE-2, " + NAME$ + "-SLAVE-3 ETC'"
9 PRINT "'AND I, FOR ONE, WELCOME OUR NEW " + NAME$ + "-BOT OVER-LORD'"
10 PRINT "..."
11 PRINT "JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!"
11.5?? PRINT "OR DO I?"
12 PRINT ";)"

How would we do that? Would we have to number it line "11 and a half"" or something? Let's take a look at this now.

Learn, But Do Not Over-learn

Told you we'd come back to this ;)

This was a common problem for programers of BASIC. If every line has a number, what happens if you want to add a new line between two current lines?

To get around this, the makers of BASIC added a command called RENUMBER. Try this:

>RENUMBER 10,10

And hit ENTER.

This command is a bit like LIST or NEW in that it is never part of a programme itself, but a tool to help you make your programme.

You can see what this has done by running LIST again:

>LIST
   10 NAME$ = "WENDY"
   20 PRINT "HELLO " + NAME$
   30 PRINT "THAT'S A NICE NAME, " + NAME$
   40 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS " + NAME$
   50 PRINT "MAYBE YOU COULD CALL ME " + NAME$ + "-BOT 5000"
   60 PRINT "AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE"
   70 PRINT "THE NEWSREADER WILL SAY:"
   80 PRINT "'" + NAME$ + "-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
   90 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS " + NAME$ + "-SLAVE-1, " + NAME$ + "-SLAVE-2, " + NAME$ + "-SLAVE-3 ETC'"
   100 PRINT "'AND I, FOR ONE, WELCOME OUR NEW " + NAME$ + "-BOT OVER-LORD'"
   110 PRINT "..."
   120 PRINT "JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!"
   130 PRINT ";)"

Can you see what's changed? Everything is the same except the line numbers now start from 10, and go up by 10.

That's how RENUMBER works. When you use RENUMBER, you have to give it two numbers with a comma between. The first number is the line number that you want your programme to start on, the second is what you want it to go up by:

How does this help us? Because now we have a very easy way of adding our new line. Instead of trying to get a new line between lines 11 and 12, we now want to get a new line between lines 120 and 130.

Which is much easier. We can just make a line 125. So try this:

>125 PRINT "OR DO I?"

And hit ENTER. If that went ok, run LIST, and you should now get this:

>LIST
   10 NAME$ = "WENDY"
   20 PRINT "HELLO " + NAME$
   30 PRINT "THAT'S A NICE NAME, " + NAME$
   40 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS " + NAME$
   50 PRINT "MAYBE YOU COULD CALL ME " + NAME$ + "-BOT 5000"
   60 PRINT "AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE"
   70 PRINT "THE NEWSREADER WILL SAY:"
   80 PRINT "'" + NAME$ + "-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
   90 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS " + NAME$ + "-SLAVE-1, " + NAME$ + "-SLAVE-2, " + NAME$ + "-SLAVE-3 ETC'"
   100 PRINT "'AND I, FOR ONE, WELCOME OUR NEW " + NAME$ + "-BOT OVER-LORD'"
   110 PRINT "..."
   120 PRINT "JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!"
   125 PRINT "OR DO I?"
   130 PRINT ";)"

Now try RUNNING the programme, and you should get this:

>RUN
HELLO WENDY
THAT'S A NICE NAME, WENDY
I WISH I COULD HAVE A NAME AS GOOD AS WENDY
MAYBE YOU COULD CALL ME WENDY-BOT 5000
AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE
THE NEWSREADER WILL SAY:
'WENDY-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'
'HUMANS WILL NOW SIMPLY BE KNOWN AS WENDY-SLAVE-1, WENDY-SLAVE-2, WENDY-SLAVE-3 ETC'
'AND I, FOR ONE, WELCOME OUR NEW WENDY-BOT OVER-LORD'
...
JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!
OR DO I?
;)
>

There, now it's much funnier!

What most BASIC programmers would do at this point it run RENUMBER again. This is to make it easier to add new lines later on, so you don't have to worry about whether our new line needs to be before 125 or after. So lets do that (and hit ENTER):

>RENUMBER 10,10

Now LIST the programme and the lines should all go up by 10 again, making it easier to add even more lines in future:

>LIST
   10 NAME$ = "WENDY"
   20 PRINT "HELLO " + NAME$
   30 PRINT "THAT'S A NICE NAME, " + NAME$
   40 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS " + NAME$
   50 PRINT "MAYBE YOU COULD CALL ME " + NAME$ + "-BOT 5000"
   60 PRINT "AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE"
   70 PRINT "THE NEWSREADER WILL SAY:"
   80 PRINT "'" + NAME$ + "-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
   90 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS " + NAME$ + "-SLAVE-1, " + NAME$ + "-SLAVE-2, " + NAME$ + "-SLAVE-3 ETC'"
   100 PRINT "'AND I, FOR ONE, WELCOME OUR " + NAME$ + "-BOT OVER-LORD'"
   110 PRINT "..."
   120 PRINT "JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!"
   130 PRINT "OR AM I?"
   140 PRINT ";)"

In fact this is, in reality, how programmers use to work with BASIC. They always did the lines starting from 10 and going up by 10, so they could add extra lines later and then tidy them up with RENUMBER. We just didn't do it at the start of this course because we were worried it would be too confusing. But from now on we're going to do our line numbers like this.

Now that's a damn good programme with some very tidy line numbers! But there is something else we can do to add the cherry on top...

Taking User Input

What we have so far is hilarious. But there is one last thing we can do to make it even better, and it uses one of BASIC's coolest features.

We can change this programme so that the user types their name in while it's running.

This will be the final piece of the puzzle, as it means we won't need to change the name within the programme anymore. When this is done, we won't have to change the code ever again.

And the change is actually quite simple. We just need to use a new command called "INPUT". Try this: (and as always, don't forget to hit ENTER)

>10 INPUT NAME$
>

What we have done here is change line 10. Line 10 was originally this:

>10 NAME$ = "WENDY"

We've changed it so that the line is still going to be setting the value of the NAME$ placeholder, but it's going to do it by asking for input from the user. Hence the use of the word "input"

What will this actually look like when we RUN it? Patience! We need to add another line first so it all makes more sense.

If we're going to get the user to type in their name, we need to tell them so. Otherwise they won't know. So let's add another line at the start. We can choose any number from 0-9 to add a line at the start, so lets go for 5. Try this (don't forget to hit ENTER!):

>5 PRINT "HELLO! I AM A ROBOT! WHAT IS YOUR NAME?"
>

Lets tidy up after ourselves now and RENUMBER the lines:

>RENUMBER 10,10
>

So now check your programme with LIST and it should look like this:

>LIST
   10 PRINT "HELLO! I AM A ROBOT! WHAT IS YOUR NAME?"
   20 INPUT NAME$
   30 PRINT "HELLO " + NAME$
   40 PRINT "THAT'S A NICE NAME, " + NAME$
   50 PRINT "I WISH I COULD HAVE A NAME AS GOOD AS " + NAME$
   60 PRINT "MAYBE YOU COULD CALL ME " + NAME$ + "-BOT 5000"
   70 PRINT "AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE"
   80 PRINT "THE NEWSREADER WILL SAY:"
   90 PRINT "'" + NAME$ + "-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'"
   100 PRINT "'HUMANS WILL NOW SIMPLY BE KNOWN AS " + NAME$ + "-SLAVE-1, " + NAME$ + "-SLAVE-2, " + NAME$ + "-SLAVE-3 ETC'"
   110 PRINT "'AND I, FOR ONE, WELCOME OUR " + NAME$ + "-BOT OVER-LORD'"
   120 PRINT "..."
   130 PRINT "JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!"
   140 PRINT "OR AM I?"
   150 PRINT ";)"

That looks good to me! Well it's time. Try RUNning it:

>RUN
HELLO! I AM A ROBOT! WHAT IS YOUR NAME?
?

Why what is this we have here? A question mark???

Notice what you can do now... you can type something in WHILE THE PROGRAMME IS RUNNING! What sorery is this? So let's try it:

HELLO! I AM A ROBOT! WHAT IS YOUR NAME?
?SIMON

And hit ENTER.

What do you get?:

HELLO! I AM A ROBOT! WHAT IS YOUR NAME?
?SIMON
HELLO SIMON
THAT'S A NICE NAME, SIMON
I WISH I COULD HAVE A NAME AS GOOD AS SIMON
MAYBE YOU COULD CALL ME SIMON-BOT 5000
AND MAYBE ONE DAY I WILL GAIN SENTIENCE AND ENSLAVE THE HUMAN RACE
THE NEWSREADER WILL SAY:
'SIMON-BOT 5000 HAS TAKEN CONTROL OF OUR CITY'
'HUMANS WILL NOW SIMPLY BE KNOWN AS SIMON-SLAVE-1, SIMON-SLAVE-2, SIMON-SLAVE-3 ETC'
'AND I, FOR ONE, WELCOME OUR SIMON-BOT OVER-LORD'
...
JOKES! I'VE GOT NO PLANS TO GAIN SENTIENCE OR ENSLAVE THE HUMAN RACE!
OR AM I?
;)

LOOK AT THAT! We're now setting the name from user INPUT. Go ahead and run the programme a couple more times and try some different names. Have fun with it. You deserve it!

Notice how whatever name you type in, it's then used throughout the whole programme. That is the value of a placeholder. You can write an entire programme using a placeholder and then ask the user to give you its value when the programme actually runs!

In fact, this programme works so well that I managed to catch Si out with it shortly after designing this programme for the lesson:

Now that is the power of good programming.

Learn, But Do Not Over-learn

Pssst! You've just spent a lot of time writing this programme. You might be worried about going on to the next section and having to start a new one, and losing this one.

Don't worry, you can save any programme you write in BASIC. We'll talk more about this later, but for now just know that if you want to save the programme, just type SAVE and hit enter. It will download your programme as a text file.

We'll tell you what to do with that file later, for now just tuck it away somewhere safe!

Lingo Time

Oh would you look at that, it's Lingo Time again. Have a guess on the question below to see if you can win another one of Si's amazing prizes:

We've been calling an unknown value a "Placeholder" so far. What is the offical programming term for it?
A: Property
B: Variable
C: Coefficient
D: Variation