Being drugged up on strepsils is not a great situation to be in, but a good way to distract oneself is to continue with Small Basic development. Last time we got some input the user and printed it back to them. Exciting stuff but quite simple. Now lets make some decisions based on what we know.
To make decisions in programming we use if statements, this is also called branching. Consider the following situation. Its 7am, your alarm is sounding off you have to make a decision. If it is a weekday then I need to get up and go to school Else if it is the weekend I can go back to sleep. That is the basic of making decisions.
Open up Small Basic with the application we created last time. Write the following line of code at the bottom of the screen
if squadron = "1074" Then
TextWindow.WriteLine("You are from the best Squadron")
EndIf
Like this:

Now its time to run the application. Type your name then 1074 into the prompts, you should see something like this:
Run the programme again but this time enter a different squadron. You should not see the “you are from the best squadron”.
We can extend this further still by using “Else” statements.
if squadron = "1074" Then
TextWindow.WriteLine("You are from the best Squadron")
Else
TextWindow.WriteLine("1074 is the best squadron. Sorry!")
EndIf
It should look like this
When running this programme with a different squadron we now see:
we have created a very basic decision making application there. You could extend it by saying “Its great that you’re from ” + squadron + ” but you should have come to 1074 instead”.
Extending it further If, elseif, end if. What if we want to make a decision based on a value but a different decision if its not that value? For example checking to see if they are from 1074 or 2328.
if squadron = "1074" Then
TextWindow.WriteLine("You are from the best Squadron")
ElseIf squadron ="2328" then
TextWindow.WriteLine("Ah you're not from 1074 but from 2328!")
Else
TextWindow.WriteLine("You're not from 1074 or 2328")
EndIf
Which outputs like:
And if I got to 739 Squadron?
There we have it. Making some simple decisions. We’ll be extending this further soon by creating loops and generating graphical user interfaces (GUIs)









































