Microsoft Small Basic

Events

Modified: 2009/11/18 16:33 by 75.217.240.199 - Uncategorized
Let's say we want a bell to ring when we click the mouse. It's easy enough to create a subroutine that rings the bell.

Sub PlayBell
  Sound.PlayBellRing()
EndSub

But how do we tell this subroutine to play when the mouse is clicked? We use something called 'events'.
This icon indicates an event

This icon indicates an event


Normally if you wanted to play the bell you would write
PlayBell()
However when setting an event, you leave off the parentheses to indicate that you are not calling the subroutine, but rather that you want the subroutine to be called.

There are many events, in this case the MouseDown event is on the GraphicsWindow so the code would look like this:

GraphicsWindow.MouseDown = PlayBell

ScrewTurn Wiki version 2.0.35. Some of the icons created by FamFamFam.