Microsoft Small Basic

Program Listing:
Embed this in your website
TextWindow.ForegroundColor="cyan"
path = Program.Directory+"\SBStories\"
ext = ".txt"
' The following line could be harmful and has been automatically commented.
' File.CreateDirectory(path)
begin:
TextWindow.Clear()
TextWindow.WriteLine("Welcome to the Story Menu")
TextWindow.WriteLine("")
TextWindow.WriteLine("Type the number of what would you like to do.")
TextWindow.WriteLine("")
TextWindow.WriteLine("1. Start a new story")
TextWindow.WriteLine("2. Load a story")
TextWindow.WriteLine("3. Exit")
q1:
a1 = "
a1 = TextWindow.ReadNumber()
If a1 = 1 Then
  Goto newstory
ElseIf a1 = 2 Then
  Goto loadstory
Elseif a1 = 3 then
  TextWindow.WriteLine("Are you sure you want to exit? (Y or N)")
  q2:
  a2 = "
  a2 = TextWindow.Read()
  If a2 = ("Y") or a2 = ("y") Then
    Program.End()
  Elseif a2 = ("N") or a2 = ("n") Then
    Goto begin
  Else
    TextWindow.WriteLine("Invalid answer. Please enter another:")
    Goto q2
  EndIf
Else
  TextWindow.WriteLine("Invalid answer. Please enter another:")
  Goto q1
EndIf
newstory:
TextWindow.Clear()
TextWindow.WriteLine("Welcome to a new story")
TextWindow.WriteLine("")
TextWindow.Write("Please enter your name: ")
name = TextWindow.Read()
TextWindow.Write("Please enter a season: ")
season = TextWindow.Read()
TextWindow.Write("Please enter a climate type (ex. cloudy): ")
climate = TextWindow.Read()
TextWindow.Write("Please enter a type of terrain (ex. jungle): ")
tot = TextWindow.Read()
TextWindow.Write("Please enter an adjective: ")
adj1 = TextWindow.Read()
TextWindow.Write("Please enter a noun: ")
n1 = TextWindow.Read()
TextWindow.Write("Please enter an adjective: ")
adj2 = TextWindow.Read()
TextWindow.Write("Please enter a noun: ")
n2 = TextWindow.Read()
TextWindow.Write("Please enter a random word/phrase: ")
rndmphrase = TextWindow.Read()
TextWindow.Write("Please enter a candy (ex. Skittles): ")
candy = TextWindow.Read()
TextWindow.Pause()
TextWindow.Clear()
TextWindow.WriteLine("Once upon a ti- No, that's too cheezy.")
TextWindow.WriteLine(name+" and some friends decided to go camping in the middle of "+season+".")
TextWindow.WriteLine("It was unusually "+climate+".")
TextWindow.WriteLine("They thought it was just the "+tot+".")
TextWindow.WriteLine("So they pitched their "+adj1+" tents and started a fire.")
TextWindow.WriteLine("They heard a noise coming from the "+n1+". ")
TextWindow.WriteLine("Out came a "+adj2+" llama and it barfed rainbows into "+name+"'s lap.")
TextWindow.WriteLine("Then the "+adj2+" llama flew away on a "+n2+"!")
TextWindow.WriteLine(name+" cried out, '"+rndmphrase+"! ")
TextWindow.WriteLine("Then "+name+" turned into a "+adj2+" llama and burst into "+candy+".")
TextWindow.WriteLine("The End")
TextWindow.Pause()
TextWindow.Clear()
TextWindow.WriteLine(name+", did you enjoy reading your story?")
TextWindow.WriteLine("")
TextWindow.WriteLine("Would you like to save your story? (Y or N?")
q3:
a3 = "
a3 = TextWindow.Read()
If a3 = "Y" or a3 = "y" Then
  Goto savefile
ElseIf a3 = "N" or a3 = "n" Then
TextWindow.WriteLine("Press any key to go back to the Main Menu.")
TextWindow.PauseWithoutMessage()
Goto begin
Else
  TextWindow.WriteLine("Invalid answer. Please enter another:")
  Goto q3
EndIf
savefile:
customstory[1] = "Once upon a ti- No, that's too cheezy. "
customstory[2] = name+" and some friends decided to go camping in the middle of "+season+". "
customstory[3] = "It was unusually "+climate+". "
customstory[4] = "They thought it was just the "+tot+". "
customstory[5] = "So they pitched their "+adj1+" tents and started a fire. "
customstory[6] = "They heard a noise coming from the "+n1+". "
customstory[7] = "Out came a "+adj2+" llama and it barfed rainbows into "+name+"'s lap. "
customstory[8] = "Then the "+adj2+" llama flew away on a "+n2+"! "
customstory[9] = name+" cried out, '"+ rndmphrase+"! "
customstory[10] = "Then "+name+" turned into a "+adj2+" llama and burst into "+candy+". "
customstory[11] = "The End"
TextWindow.Clear()
TextWindow.WriteLine("Please enter the desired filename for your story:")
filename = TextWindow.Read()
' The following line could be harmful and has been automatically commented.
' File.WriteContents(path+filename+ext, customstory)
TextWindow.WriteLine("Press any key to go back to the Main Menu.")
TextWindow.PauseWithoutMessage()
Goto begin
loadstory:
TextWindow.Clear()
TextWindow.WriteLine("Please write the name of the file you wish to load.")
TextWindow.WriteLine("")
TextWindow.WriteLine("Note: The filename must match the name you saved the story as exactly")
TextWindow.WriteLine("or load will be unsuccessful.")
TextWindow.WriteLine("")
loadname = TextWindow.Read()
' The following line could be harmful and has been automatically commented.
' loadedfile = File.ReadContents(path+loadname+ext)
TextWindow.WriteLine(loadedfile[1])
TextWindow.WriteLine(loadedfile[2])
TextWindow.WriteLine(loadedfile[3])
TextWindow.WriteLine(loadedfile[4])
TextWindow.WriteLine(loadedfile[5])
TextWindow.WriteLine(loadedfile[6])
TextWindow.WriteLine(loadedfile[7])
TextWindow.WriteLine(loadedfile[8])
TextWindow.WriteLine(loadedfile[9])
TextWindow.WriteLine(loadedfile[10])
TextWindow.WriteLine(loadedfile[11])
TextWindow.PauseWithoutMessage()
Goto begin
Copyright (c) Microsoft Corporation. All rights reserved.