kids encyclopedia robot

Microsoft Small Basic facts for kids

Kids Encyclopedia Facts
Quick facts for kids
Microsoft Small Basic
Small Basic.png
Paradigm Structured, imperative, object-oriented
Designed by Microsoft, Vijaye Raji
Developer Microsoft
First appeared October 23, 2008; 16 years ago (2008-10-23)
Stable release
v1.2 / October 1, 2015; 9 years ago (2015-10-01)
Typing discipline Dynamic, weak
Platform .NET Framework 4.5
OS Small Basic Desktop: Windows XP (up to version 1.0), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008 R2
Small Basic Online: web browser
License MIT License
Filename extensions .sb, .smallbasic
Influenced by
Logo, QBasic, Visual Basic .NET

Microsoft Small Basic is a special computer language made by Microsoft. It's designed to help kids and beginners learn how to write computer programs. If you've used visual programming tools like Scratch, Small Basic helps you move to writing code using text. It comes with a simple program editor. This editor helps you write code by highlighting words and suggesting what to type next. It also gives you help right there in the program. Small Basic uses only 14 special words, making it super easy to learn!

History of Small Basic

Microsoft first talked about Small Basic in October 2008. They released the first full version on July 12, 2011. This release came with lessons and a guide to help people learn. Before the full release, they made several test versions. These were called Community Technology Previews (CTP).

Version Release date
Old version, no longer maintained: v0.1 October 23, 2008
Old version, no longer maintained: v0.2 December 17, 2008
Old version, no longer maintained: v0.3 February 10, 2009
Old version, no longer maintained: v0.4 April 14, 2009
Old version, no longer maintained: v0.5 June 16, 2009
Old version, no longer maintained: v0.6 August 19, 2009
Old version, no longer maintained: v0.7 October 23, 2009
Old version, no longer maintained: v0.8 February 4, 2010
Old version, no longer maintained: v0.9 June 11, 2010
Old version, no longer maintained: v0.91 November 17, 2010
Old version, no longer maintained: v0.95 February 8, 2011
Older version, yet still maintained: v1.0 July 12, 2011
Old version, no longer maintained: v1.1 March 27, 2015
Current stable version: v1.2 October 1, 2015
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release

On March 27, 2015, Microsoft released Small Basic version 1.1. This update fixed a problem. It also changed the required .NET Framework version. This meant version 1.1 could not run on Windows XP.

Microsoft released Small Basic version 1.2 on October 1, 2015. This was the first big update in four years. It added new features to Small Basic. The update included tools for working with Microsoft's Kinect motion sensors. It also added more languages to the Dictionary tool. Plus, it fixed several other problems.

On February 19, 2019, Microsoft announced Small Basic Online (SBO). This is a free and open-source version. It is available for anyone to use and change.

How Small Basic Works

Small Basic is a powerful language. It can do anything a computer program can do. You can make programs that make choices. You can also make programs that repeat actions. It supports special sections of code for handling events. Variables in Small Basic are flexible. They can change their type as needed.

Writing Your First Program

Here is how you write the classic "Hello, World!" program in Small Basic:

TextWindow.WriteLine("Hello, World!")

This simple code tells the computer to show the words "Hello, World!" on the screen.

Making Choices with Code

Small Basic lets your programs make decisions. This is called conditional branching. The example below asks if you use Celsius or Fahrenheit. Then it gives advice based on the temperature you enter.

' A Program that gives advice at a requested temperature.
TextWindow.WriteLine("Do you use 'C'elsius or 'F'ahrenheit for temperature?")
TextWindow.WriteLine("Enter C for Celsius and F for Fahrenheit:")
question_temp: ' Label to jump back to input if wrong input was given
tempunit = TextWindow.Read()
' Temperature Definitions in Celsius:
tempArray["hot"] = 30     ' 30 °C equals 86 °F
tempArray["pretty"] = 20  ' 20 °C equals 68 °F
tempArray["cold"]= 15     ' 15 °C equals 59 °F

If tempunit = "C" OR tempunit = "c" Then
  TextWindow.WriteLine("Celsius selected!")
  tempunit = "C" ' Could be lowercase, thus make it uppercase
ElseIf tempunit = "F" OR tempunit = "f" Then
  TextWindow.WriteLine("Fahrenheit selected!")
  ' We calculate the temperature values for Fahrenheit based on the Celsius values
  tempArray["hot"] = ((tempArray["hot"] * 9)/5) + 32
  tempArray["pretty"] = ((tempArray["pretty"] * 9)/5) + 32
  tempArray["cold"] = ((tempArray["cold"] * 9)/5) + 32
  tempunit = "F" ' Could be lowercase, thus make it uppercase
Else
  GOTO question_temp ' Wrong input, jump back to label "question_temp"
EndIf
TextWindow.Write("Enter the temperature today (in " + tempunit +"): ")
temp = TextWindow.ReadNumber()
If temp >= tempArray["hot"] Then
  TextWindow.WriteLine("It is pretty hot.")
ElseIf temp >= tempArray["pretty"] Then
  TextWindow.WriteLine("It is pretty nice.")
ElseIf temp >= tempArray["cold"] Then
  TextWindow.WriteLine("Don't forget your coat.")
Else
  TextWindow.WriteLine("Stay home.")
EndIf

Small Basic uses `If` and `ElseIf` to check conditions. It then runs different code based on what is true.

Repeating Actions with Loops

Loops help you repeat actions in your program. This example shows a loop that multiplies numbers. It starts from 1 and goes up to 10. Each number is multiplied by four. The result is then shown on the screen.

TextWindow.WriteLine("Multiplication Tables")
For i = 1 To 10
  TextWindow.Write(i * 4)
EndFor

You can also use `While` loops to repeat actions as long as a condition is true. The `For` loop can use a `Step` keyword. This lets you change how much the counter increases each time.

Understanding Data Types

Small Basic handles different kinds of information. These are called data types. It supports text (strings), whole numbers (integers), and numbers with decimals. Small Basic is smart. It can often change one type to another when needed.

Look at this example:

TextWindow.WriteLine("Enter your name: ")
name = TextWindow.Read()

TextWindow.Write("Enter your age: ")
age = TextWindow.ReadNumber()

TextWindow.WriteLine("Hello, " + name + "!")
TextWindow.WriteLine("In 5 years, you shall be " + ( age + 5 ) + " years old!")

The `Read` method gets text. The `ReadNumber` method gets numbers. Small Basic knows how to add numbers together. It also knows how to combine text.

Here is another example:

TextWindow.WriteLine(Math.log("100")) 'Prints 2
TextWindow.WriteLine("100" + "3000") ' Prints 3100
TextWindow.WriteLine("Windows " + 8) ' Prints Windows 8
TextWindow.WriteLine(Text.GetLength(1023.42)) ' Prints 7 (length of decimal representation including decimal point)

In the second line, "100" and "3000" are text. But Small Basic treats them as numbers. It adds them to get 3100. If you want to join them as text, you use `Text.Append("100", "3000")`. This would give you "1003000".

Small Basic Libraries

Small Basic has a built-in collection of tools. These are called the standard library. They help you do math, work with text, and handle input and output. There are also fun tools for learners.

Fun Tools for Learning

Small Basic includes special tools to make learning fun. For example, there's a "Turtle graphics" tool. This lets you draw shapes using simple commands. There's also a tool for getting pictures from Flickr. You can even use tools to interact with Microsoft Kinect sensors.

Here's how easy it is to get a random mountain picture from Flickr and set it as your desktop wallpaper:

For i = 1 To 10
  pic = Flickr.GetRandomPicture("mountains")
  Desktop.SetWallPaper(pic)
  Program.Delay(10000)
EndFor

Drawing with Turtle Graphics

The "Turtle" graphics tool is inspired by the Logo programming language. Imagine a tiny turtle with a pen. You tell it to move and turn. As it moves, it draws a line.

To draw a square, you tell the turtle to move forward. Then you tell it to turn 90 degrees. You repeat these two steps four times.

For i = 1 to 4
  Turtle.Move(100) ' Forward 100 pixels
  Turtle.Turn(90) ' Turn 90 degrees right
EndFor

You can draw more complex shapes too. Just change the turning angle and how many times the loop runs. For example, to draw a hexagon, you turn 60 degrees and repeat six times.

Adding More Tools

You can also add tools made by other people to Small Basic. These are called third-party libraries. They must be written in a special way for Small Basic to understand them. If these extra tools come with instructions, the Small Basic editor can show them to you. This makes it easier to use them in your programs.

kids search engine
Microsoft Small Basic Facts for Kids. Kiddle Encyclopedia.