Introduction

Series of know issues articles are showing known issue itself about Small Basic and it's workaround.

Phenomenon

Following code registers mouse down event in line 5.  But this is after the definition (line 2).

1.GraphicsWindow.MouseDown = OnMouseDown
2.Sub OnMouseDown
3.  GraphicsWindow.MouseDown = DoNothing
4.  ' do somthing for mouse down
5.  GraphicsWindow.MouseDown = OnMouseDown
6.EndSub
7.Sub DoNothing
8.EndSub

In this kind of case, Small Basic causes compile error such as below.

Sorry, we found some errors...
5,30: The variable 'OnMouseDown' is used, but its value is not assigned.  Are you sure you have spelled it correctly?

Workaround

Adding such as lines 9-10 below will be a workaround.

1.GraphicsWindow.MouseDown = OnMouseDown
2.Sub OnMouseDown
3.  GraphicsWindow.MouseDown = DoNothing
4.  ' do somthing for mouse down
5.  GraphicsWindow.MouseDown = OnMouseDown
6.EndSub
7.Sub DoNothing
8.EndSub
9.Sub Dummy
10.  OnMouseDown = ""
11.EndSub

See Also