Microsoft Small Basic

Program Listing: LTH176
TextWindow.Title = "Metaprogramming"

Start:

TextWindow.WriteLine ("Small Basic tutorial in Small Basic")
TextWindow.Read()
TextWindow.WriteLine ("by GORS")
TextWindow.Read()
TextWindow.WriteLine ("Thanks to SENGIR who taught me and several others how to program in Small Basic!")
TextWindow.Read()
TextWindow.Write ("Hello, stranger!")

Nameentry:

TextWindow.WriteLine (" What's your name?")
TextWindow.Write (">")
name = TextWindow.Read()
uname = Text.ConvertToUpperCase (name)

If uname = "" Then
TextWindow.WriteLine ("You didn't type anything!")
TextWindow.Read()
Goto Nameentry
EndIf

Nameconfirm:

TextWindow.WriteLine ("Is your name " + uname + "? Y/N")
answer = TextWindow.Read()
uanswer = Text.ConvertToUpperCase (answer)

If uanswer = "Y" Then
Goto Programstart
ElseIf uanswer = "N" Then
TextWindow.WriteLine ("Then,")
TextWindow.Read()
Goto nameentry
Else
TextWindow.WriteLine ("That's not a valid answer.")
TextWindow.Read()
Goto Nameconfirm
EndIf

Programstart:

TextWindow.WriteLine ("Hello, " + uname + "!")
TextWindow.Read()
TextWindow.WriteLine ("This is Gors' Small Basic tutorial in Small Basic!")
TextWindow.Read()
TextWindow.WriteLine ("Small Basic is a simple programming language created by Microsoft in November 2008. As the name implies, it's a simplified version of BASIC.")
TextWindow.WriteLine ("Here, you'll learn how to use some of its features! Open up Small Basic, and be prepared!")
TextWindow.Read()
TextWindow.WriteLine ("Let's start with a 'Hello World' text string, " + uname + "!")
TextWindow.Read()
TextWindow.WriteLine ("To make Small Basic to print your text, you need to type this in the Small Basic's notepad:")
TextWindow.Read()
q = Text.GetCharacter(34)
TextWindow.Writeline ("TextWindow.Writeline (" + q + "Hello World" + q + ")")
TextWindow.Read()
TextWindow.Writeline ("Then, press F5 to execute your program! Easy, isn't it?")
TextWindow.Read()
TextWindow.Writeline ("Now let's understand what happened there, " + uname + "!")
TextWindow.Read()
TextWindow.Writeline (q + "TextWindow" + q + " is an OBJECT. They're the basis for everything Small Basic can do!")
TextWindow.Read()
TextWindow.Writeline ("The" + q + "TextWindow" + q + " OBJECT gives you several options to work with text, as its name implies. So, if you intend to show text to the user, you may want to use this a lot.")
TextWindow.Read()
TextWindow.WriteLine ("Next to the OBJECT, you can see " + q + "WriteLine" + q + ". That is a METHOD, or in simpler words, a task the OBJECT can do.")
TextWindow.Read()
TextWindow.WriteLine ("The " + q + "WriteLine" + q + " METHOD prints all the text input on the screen. So, everything you saw here was mostly done with " + q + "TextWindow.Writeline" + q + "!")
TextWindow.Read()
TextWindow.WriteLine ("So, analoguelly saying, TextWindow is a kind of 'BAG' with several 'TOOLS' inside it. One of these 'TOOLS' is WriteLine, which will work once you give it a task.")
TextWindow.Read()
TextWindow.WriteLine ("The tasks come inside parenthesis " + q + "()" + q + ", and those parenthesis can have plain text and VARIABLES, which will be explained soon!")
TextWindow.Read()
TextWindow.WriteLine ("This code has 'Hello World' as plain text, as the quotation marks imply.")
TextWindow.WriteLine ("If you just want a quick text, you can simply write it inside quotation marks.")
TextWindow.Read()
TextWindow.WriteLine ("But, if you want a text, or value, to be repeated through the code, you may want a VARIABLE.")
TextWindow.Read()
TextWindow.WriteLine ("A VARIABLE works like the ones you find in math. In the equation:")
TextWindow.Read()
TextWindow.WriteLine ("x=2")
TextWindow.Read()
TextWindow.WriteLine ("you can see that 'x' equals 2. You can then use this 'x' in other equations to quickly make math operations:")
TextWindow.Read()
TextWindow.WriteLine ("x+3 (which will give you 5);")
TextWindow.Read()
TextWindow.WriteLine ("4x (which will give you 8);")
TextWindow.Read()
TextWindow.WriteLine ("x-1 (which will give you 1), and so on.")
TextWindow.Read()
TextWindow.WriteLine ("Small Basic uses this same logic for its programming, but the twist is that they accept words as variables! So, you can write this:")
TextWindow.Read()
TextWindow.WriteLine ("x = " + q + "Hello World" + q)
TextWindow.WriteLine ("TextWindow.WriteLine (x)")
TextWindow.Read()
TextWindow.WriteLine ("That code says that you've set a VARIABLE, named 'x', and gave it the 'Hello World' value.")
textwindow.WriteLine ("This value is returned in the WriteLine METHOD. Notice the same 'x' VARIABLE inside the parenthesis.")
TextWindow.Read()
textwindow.WriteLine ("You can use variables for several things! your name, " + uname + ", for example, is an VARIABLE!")
TextWindow.Read()
textwindow.WriteLine ("I hope you enjoyed reading through this tutorial. I am still a beginner and some things might be wrong, but you gotta learn it by trying!")
TextWindow.Read()
textwindow.WriteLine ("Thank you, " + uname + "!")
TextWindow.Read()