Small Basic #7: Odds and Ends - Sound, Program, and Stack
A few more Microsoft Small Basic classes with very methods and properties are:
- The Sound class, which allows you to work with a computer's sounds and sound files.
- The Program class, which allows you to work with a running Small Basic program.
- The Stack class, which allows you to work with a stack, which is a simple temporary storage area in a computer's memory. A stack is like a pile of coins: you can add items one on top of another only; you can look at only the top item; and you can remove items from only the top down.
' Sound class.
WINDOWS_MEDIA_PATH = "C:\Windows\Media\"
Sound.Play(WINDOWS_MEDIA_PATH + "Windows Notify.wav")
DelayProgram()
Sound.PlayAndWait(WINDOWS_MEDIA_PATH + "Windows Exclamation.wav")
DelayProgram()
Sound.PlayBellRing()
DelayProgram()
Sound.PlayBellRingAndWait()
DelayProgram()
Sound.PlayChime()
DelayProgram()
Sound.PlayChimeAndWait()
DelayProgram()
Sound.PlayChimes()
DelayProgram()
Sound.PlayChimesAndWait()
DelayProgram()
Sound.PlayClick()
DelayProgram()
Sound.PlayClickAndWait()
Sub DelayProgram
Program.Delay(2000)
EndSub
' Program class.
' If you start a Small Basic program from the command line, you can pass arguments to it.
' (Look for the .exe file in the same directory as the corresponding .sb file.)
TextWindow.WriteLine("Number of arguments is: " + Program.ArgumentCount + ".")
TextWindow.WriteLine("Program's directory is: " + Program.Directory + ".")
TextWindow.WriteLine("First argument is: " + Program.GetArgument(1) + ".")
Program.Delay(2000)
Program.End()
' Stack class.
Stack.PushValue("first stack", "first stack, 1")
Stack.PushValue("first stack", "first stack, 2")
Stack.PushValue("first stack", "first stack, 3")
Stack.PushValue("second stack", "second stack, 1")
Stack.PushValue("second stack", "second stack, 2")
Stack.PushValue("second stack", "second stack, 3")
Stack.PushValue("second stack", "second stack, 4")
TextWindow.WriteLine("First stack has " + Stack.GetCount("first stack") + " items.")
TextWindow.WriteLine("Second stack has " + Stack.GetCount("second stack") + " items.")
TextWindow.WriteLine("Top item on first stack is: " + Stack.PopValue("first stack") + ".")
TextWindow.WriteLine("Top item on second stack is: " + Stack.PopValue("second stack") + ".")
TextWindow.WriteLine("After popping, top item on first stack is: " + Stack.PopValue("first stack") + ".")
TextWindow.WriteLine("After popping, top item on second stack is: " + Stack.PopValue("second stack") + ".")