Microsoft Small Basic

Program Listing: ZWF718-1
' Piano 0.1
' Copyright (c) 2010, 2012 Nonki Takahshi. All rights reserved.
'
' History :
' 0.1 2012/08/07 Title and background color added.
' 0.0 2010/07/21 Created for the 25 line challange in Small Basic Forum ()
'
GraphicsWindow.Title = "Piano 0.1"
GraphicsWindow.BackgroundColor = "#222222"
sKey = "awsedftgyhujkolp;"
sSharp = "## ### ## "
sWhite = "ASDFGHJKL;"
sBlack = "WE TYU OP "
sMML = "O4C8 O4C#8O4D8 O4D#8O4E8 O4F8 O4F#8O4G8 O4G#8O4A8 O4A#8O4B8 O5C8 O5C#8O5D8 O5D#8O5E8 "
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(107, 110, 400, 200)
For i = 1 To 10
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawRectangle(67 + i * 40, 110, 40, 200)
GraphicsWindow.DrawText(70 + i * 40, 290, Text.GetSubText(sWhite, i, 1))
If Text.GetSubText(sSharp, i, 1) = "#" Then
GraphicsWindow.FillRectangle(91 + i * 40, 110, 32, 140)
GraphicsWindow.BrushColor = "White"
GraphicsWindow.DrawText(94 + i * 40, 230, Text.GetSubText(sBlack, i, 1))
EndIf
EndFor
GraphicsWindow.KeyUp = OnKeyUp
While "True"
Program.Delay(500)
EndWhile

Sub OnKeyUp
sLast = GraphicsWindow.LastText
sNote = Text.GetSubText(sMML, (Text.GetIndexOf(sKey, sLast) - 1) * 5 + 1, 5)
Sound.PlayMusic(sNote)
EndSub