Making Decisions with Small Basic

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”.

2328 output textWe 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

If 1074 Sqn Then Best Else not best. End if. When running this programme with a different squadron we now see:

Printing 1074 Best Squadron messagewe 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

 Making more than one decision Small basic

Which outputs like:

WO Jackson imposter at 2328

And if I got to 739 Squadron?

Neither Sqn

There we have it. Making some simple decisions. We’ll be extending this further soon by creating loops and generating graphical user interfaces (GUIs)

Air Cadets , ,

Installing DHCP Server Role

DHCP is one of the core roles in any network, most networks have them – yes even your home network will have one, probably in your router/modem device.

You can download a powerpoint on DHCP that I gave to Level 6 Students below:

DHCP Powerpoint

To install DHCP Server Role you should be running Windows Server 2008 R2. Click on the Server Manager icon in the taskbar and click on roles so you see this screen:

Server Manager Add RolesClick on Add Roles so this appears:

Role RecommendationsClick Next. On the next screen you’ll see a list of available roles. Check DHCP Server, the following screen will appear with some extra information for you to configure:

Install DHCP RoleClick Next. You’ll see some information about DHCP, what it can do and information that you should be aware ofIntroduction to DHCP Server

Click next. Now we can choose what network connections we want to blast DHCP on. Note you cannot distribute DHCP addresses on a connection that has a DHCP configured address. You should use static IP addresses for your DHCP Servers.

DHCP Network BindingsClick Next. You’ll end up on DNS. DNS is important on any network as without many things do not work. Choose your DNS settings carefully and thoughtfully. Note the green tick, this means the server is a valid  DNS Server

DHCP DNS settingsClick Next to get to the WINS screen (Windows Internet Naming Service) This is an old product and is not used much in modern networks (Gobal names replaced it). We don’t need it.

DHCP WINSClick next and we’ll start configuring DHCP Scopes.

Add DHCP ScopeClick on the Add Button. You’ll see something similar below. Fill it out to match your network settings

DHCP Scope OptionsClick OK and you’ll be returned to your previous screen. You can add more scopes if you need to. Click Next (red).

DHCP ScopesNext its time for DHCP Stateless mode. IPv6 supports clients natively and locally creating IPv6 addresses. Leave the default checked if you want to support IPv6.

DHCP Stateless ModeClick Next. Configure the IPv6 settings information. ::1 is IPv6 speak for localhost. Leave these as defaults and click next.

IPv6 DHCP DNS settingsNext its time to Authorise the DHCP Server onto the Active Directory Domain. Its recommended to have a DHCP administrator account, but in this example we’ll rock with administrator. Click Next. (you can also authorise the DHCP server later)

DHCP AuthorisationThe next screen is the summary screen. Read over the information and hit install.

Install DHCPOnce completed you’ll see something like this. Thats it, job done.

DHCP Install complete

Server 2008 R2 , , ,

Doing more with Small Basic

So we’ve created a very basic Small Basic Program (here). Now we’re going to add some functionality. We’re going to get some input from the user and use this information to make some informed decisions.

Start off by opening up Small Basic and creating a new project. Save this as 1074isTheBest

The first stage is write some output to tell the user what to do.
TextWindow.WriteLine("Enter your name")


Then under that create a variable called name and assign it to what the user will type, like this:
name = TextWindow.Read()

You should see something like this on your screen:

Creating a Variable Small BasicNext we need to do something with this information. Lets print it.

Write: TextWindow.WriteLine("Hello " + name)

Note the space after the hello so that there is a gap between the hello and their name. Now lets run the program.

Hello CI LangmeadYou’ll see that whatever you write will be outputted after the hello. Experiment with a variety of names and see what happens.

Write some output that asks for the squadron number and a variable to store the user response, similar to above. You could now print something a little more advanced like below:

Dominic Langmead Small BasicThis will give some output similar to this:

Small Basic variable output with text

Next time we’ll look at some conditional branching.

 

Air Cadets ,

An introduction to SmallBasic

In this post we’ll discuss your very first windows application written in Small Basic. Small Basic is a free beginner tool from Microsoft that demonstrates the very basics of programming against the Visual Basic runtime. You can download it at smallbasic.com

First things first, lets open up SmallBasic and take a look around:

Interactive Development Environment
In the box where “untitled” reads is where we type our application logic, or code to make the program do something.

We’re going to start by writing “hello 1074 Sqn”. In the window type

TextWindow.WriteLine("Hello 1074")

As you start to type you’ll see some Intellisense like below:

IntellisenseOnce you’ve written the command click the play button in the top right, or press F5. You’ll see the following output:

Program Running

Press any key to continue and you’ll be returned to to your application.

Next time we’ll look at extending this simple application.

Air Cadets , ,

Setting up Active Directory

So we’re wanting to have a play with Active Directory. How the heck do we do that as Heidi Spring Jones at the University of Chester would say. Well its quite simple.

First, you may to read my very rough guide to Active Directory, what it does, what domains are, forests, functional levels and other wonderful things here. You may also want to have a tactical Google if you’re completely new to the idea.

Command Prompt or Graphical User interface?

As with everything in Windows there is a GUI supporting most CLI ways of doing things. If you a mentalist with a tea addiction feel free to have a go at the command line install of Active Directory. I’m going to be normal and use the wizard. (Note there is no wizard on Server core!)

Step1: 

Login into your computer. Make sure it has a sensible Computer name &  static IPv4 address. Click Start and in the search box type “dcpromo.exe” and hit enter.

Start dcpromo.exe
You will then get a “Welcome to Active Directory” screen as shown below. Click Next.

Welcome to Active DirectoryIf you are running Server 2008/R2 (WHICH YOU SHOULD!) then you will see this lovely warning message about older windows operating systems. Click Next.

Operating System Compat

This is the exciting bit now. We’re setting up a brand new domain, in a brand new forest. Click “Create a new domain in a new forest” then click Next (In red)

A new forestThe next screen is where we choose our domain name. It has to be a FQDN (Fully qualified domain name) (domainname.suffix) Choose this name and click next. I chose dimdom.internal

dimdom.internalYou will then get a couple of dialogue boxes informing you of verifying the forest, DNS and netBios names. These boxes will look a little like this:

006

007 Next the wizard will auto complete to the next screen. Forest Functional Level. It is important that you know what this means. If you set the forest Level to Server 2008/R2 you restrict the editions of windows you can use to host directory databases (domain controllers). I chose 2003 as for some of the blog posts I will need Server 2003 domain controllers. If you know you will only be hosting Server 2008R2 or later domains, use that for the forest.

Click Next once you’ve decided.

Forest LevelThe next screen is the DOMAIN functional Level. You’ll note you cannot set this to lower than the forest level. If you set the highest forest level possible you may not see this screen.

Select the domain level and hit next.

Domain LevelNext its the additional components. It is recommended to host DNS with Active Directory. I recommend you stick to best practices and keep them together also. You’ll note you can set the first domain controller in a domain to be a RODC.

DNS Global CatalogNext is where you will be shouted at for having DHCP’d IP addresses. You should have static IPv4 addresses, I’m not using IPv6 so didn’t bother setting one. Click Continue anyway.

DHCP AddressesNext you will be told off about the domain name system. Click Yes.

Click YesNext its where the databases will live. In a dev environment leave these where they are. In a production environment keep them off C:\ drive. Sysvol could get very big so allow some room for it.

Click Next.

SysVolNext, its the Domain Restore password – the password you use when running in Active Directory Restore Mode. Remember this password! Click next.

Restore PasswordSummary is next. You can export the settings to a text file if you want to run them on a server core as an answer file. Or hit finish. Click back to change any of the settings.

SummaryThe wizard will then work some magic Finish

Click Finish. Then restart.

RestartOnce rebooted your domain is created and your server the first domain controller! Job complete. Well done. Get a brew and watch some of Downton Abbey as a treat.

Server 2008 R2 ,