Ok, enough of all these tiny little programmes designed for learning. Let's build something proper. Let's build a full-blown personality test!
First of all, we are going to have to learn a couple more new BASIC commands to help us get it just right.
The first new command we will learn is CLS.
This command is dead simple. It simply tells BASIC to clear the screen. Try opening a new BASIC tab, or refreshing the browser in your current tab, so you get this screen again:
Now let's give it a try. Type CLS into BASIC like this:
Hit ENTER and see what happens.
Well look at that, it cleared everything from the screen. Now you have this:
You can still carry on doing things with BASIC, all it did was clear all text that was there already. So you can now still do this, give it a go:
When used within a programme, CLS does that exact same thing. Try this:
Now try RUNning it:
And you get this:
See what happened? CLS in a programme cleared all the text on screen when its line got hit.
This is the power of CLS. By removing all text from the screen, it gives your programmes a far tidier appearance.
The next command we need to have a look at is a command for pausing programmes while they are running.
The next new command that will help us build our personality test is TEMP=GET. Yes: TEMP followed by an equals sign followed by GET.
This command will pause the programme until the user presses any key. It's actually quite similar to INPUT, except it continues as soon as they press any key.
Try this. Start a NEW programme:
And try these lines:
RUN this programme and you will get:
See how it is waiting on line 10, similar to what INPUT does?
So go ahead, press a key and you get the hilarious punchline:
That's essentially what TEMP=GET is for, having this "PRESS ANY KEY TO CONTINUE" kind of functionality.
That's great and all. But why exactly does this command consist of two words with an equals sign between them, when every other command we've learned in BASIC so far has been one word with no equals sign?
All will be revealed later. For now, just know that TEMP=GET is how you pause a programme until the user presses a key.
There's one more command we need to learn in order to make our personality test, and it's probably the most useful one yet...
The final command we need to learn is AUTO. This is a command that saves you having to write the line numbers. This is very useful when creating big programmes like the one we plan on making (did I mention it's going to be biiiiiig!).
Give this a go, start a NEW programme again:
Now type in AUTO and press ENTER:
Ooh look at that! It's put a little "10" on there that we can type on top of!
Try this and hit ENTER:
See what happened there? It's automatically made what you just typed line 10, and now moved on to line 20! So continue with this:
Now it's put us onto 30! How good is that? It's like having a servant whose only job is to give you the next line number! Finish the programme with this:
We are done with the programme now, so we don't actually want to make a line 40. But we are still in AUTO mode! Are we trapped here forever? Do we have to continue writing lines of code until the end of time?
No, simple hit ESCAPE on your keyboard to come out of AUTO mode:
Now try RUNning the programme:
And look at that! You just wrote a three line programme in record time, all because the AUTO command saved you having to put in the line numbers!
Boy, that sure will be useful when the amount of lines we'll be writing is much higher than three, because...
Ok secret coder, you've come this far. You've learned about strings, integers, variables, random numbers, CLS, TEMP=GET and AUTO. Now it's time to put it all together to make something big and meaningful. I won't lie, this programme is long. But when you finish it, you'll be a different type of programmer to who you were when you started it.
Start off with a NEW programme again:
Now go into AUTO mode:
And now, do this:
WOW did you get through all that? Now hit ESCAPE.
Trying running the programme to see if there's any mistakes.
Once any mistakes have been fixed, you should be able to do the quiz. You can even run the programme again and hand the computer to a friend or family member to give it a try. Make sure to tell them that it is your creation!
If you have got this far, then congratulations. I am well aware that this is a lot of code to write, for a language that is not in wide-spread use anymore. I made Secrets Of Coding because I wanted anybody who wanted to learn how to code to be able to without any barriers, as long as they were willing to put in the effort. If you have managed to get this far, then it means you are serious about learning how to code, and you probably do have the persistence to get there. I personally do not think anybody will get this far, so I stopped writing lessons here. Sadly I think it will always be the case that there will be a lot more money in writing code than in teaching it - I will probably never make back the money I spent on this project, and will be better off going back to my day job. But if you did finish that personality quiz, then I am telling you that you do have something special, and you can learn this even if it feels impossible right now. Please email me at jonathan.miles@hotmail.co.uk and I will genuinely try to help you get to the next stage of your learning.
And if this is the last we see of each other... than I hope you enjoyed the ride. Until next time, Secret Coder!