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 and a tool that helps you write computer programs. It's like a simplified version of the BASIC language, made by Microsoft. Small Basic is designed to help students, especially those who have used visual coding tools like Scratch, learn how to write code using text.

The tool that comes with Small Basic is called an IDE. It makes coding easier by highlighting words, helping you complete code, and giving you help right inside the program. Small Basic uses only 14 special words to do its job, making it easy to learn!

How Small Basic Started

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 put out several test versions for people to try.

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 and made the program work with a newer version of the .NET Framework. Because of this, version 1.1 could no longer run on older computers using Windows XP.

Small Basic version 1.2 came out on October 1, 2015. This was the first major update in four years to add new things. It allowed Small Basic to work with Microsoft's Kinect motion sensors. It also added more languages to the built-in dictionary and fixed several bugs.

In February 2019, Microsoft announced Small Basic Online (SBO). This version is open source, meaning its code is available for anyone to see and use. It was released under the MIT License on GitHub.

How the Language Works

Small Basic is a powerful language, even with its simple design. It can do anything a computer can do, which is called being Turing complete. It lets you make choices in your code, repeat actions, and handle special events. Variables (which store information) can change their type easily and work anywhere in your program.

Saying "Hello, World!"

In Small Basic, you can write the classic "Hello, World!" program like this:

TextWindow.WriteLine("Hello, World!")

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

Making Choices (If/Then)

Small Basic lets your program make decisions using "If" statements. Here's an example that asks about temperature and gives advice:

' 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

This code checks what the user types and then gives different advice based on the temperature.

Repeating Actions (Loops)

You can make your program repeat actions using "loops." This example shows a loop that multiplies numbers from 1 to 10 by four:

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

The `For` loop makes the computer do the multiplication ten times. You can also use `While` loops to repeat actions as long as a condition is true. The `Step` keyword lets you change how much the number increases each time.

Types of Data

Small Basic understands different kinds of data, like words (called strings) and numbers (like whole numbers or decimals). It can often change one type of data to another automatically.

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!")

Here, `Read()` gets text, and `ReadNumber()` gets numbers. Small Basic knows how to add numbers together, even if they started as text.

Sometimes, Small Basic treats numbers as text and text as numbers.

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 treated as numbers and added to make 3100. If you want to join them as text (like "1003000"), you need to use a special command: `Text.Append("100", "3000")`.

Built-in Tools (Libraries)

Small Basic comes with many useful tools, called a standard library. These tools help with math, working with text, and showing things on the screen. There are also fun tools, like a "Turtle graphics" class and a way to get pictures from Flickr.

These tools are made simple for new coders. For example, 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

This code repeats 10 times, getting a new mountain picture and changing your wallpaper every 10 seconds.

Turtle Graphics

Small Basic has a "Turtle" graphics library, similar to the Logo language. You can tell a virtual "turtle" to move and turn, and it draws lines as it goes.

To draw a square using the turtle:

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

The turtle moves forward 100 pixels, then turns 90 degrees. It repeats this four times to draw a square. You can draw more complex shapes by changing the turn angle and how many times the loop runs. For example, a hexagon needs a 60-degree turn repeated six times.

Images for kids

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