Microsoft Small Basic

Program Listing: QZZ047
' 99 Bottles of Beer
' Copyright (c) 2014 Nonki Takahashi. The MIT License.
'
InitSong()
s = "s"
max = 99
x = max
For n = max To 0 Step -1
TextWindow.Write(x + " bottle" + s + " of beer on the wall, ")
Sound.PlayMusic(mml[1])
TextWindow.WriteLine(Text.ConvertToLowerCase(x) + " bottle" + s + " of beer.")
Sound.PlayMusic(mml[2])
If n = 0 Then
TextWindow.Write("Go to the store and buy some more, ")
Else
TextWindow.Write("Take one down, pass it around, ")
EndIf
Sound.PlayMusic(mml[3])
If n = 2 Then
s = ""
x = n - 1
ElseIf n = 1 Then
s = "s"
x = "No more"
ElseIf n = 0 Then
s = "s"
x = max
Else
s = "s"
x = n - 1
EndIf
TextWindow.WriteLine(Text.ConvertToLowerCase(x) + " bottle" + s + " of beer on the wall.")
Sound.PlayMusic(mml[4])
TextWindow.WriteLine("")
EndFor
Sub InitSong
mml[1] = "E-8E-8E-8 E-4E-8 E-4R8"
mml[2] = "F8F8F8 C8C8C8 F4R8 R8R8R8"
mml[3] = "D4D8 D8R4 D8D8D8 D4R8"
mml[4] = "C8C8D8 E-4E-8 E-4R8"
EndSub