We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Small Basic Program Conversion to C#
#7
Hi JR, 

Tricky, you are right.  We can see that it occurs on 5 lines where events are set.  SmallBasicCallback is a delegate to a function (basically a variable that is actually a function).  m_onmenu is a variable (Primitive) and onmenu is the function we actually want.  Why it has called it m_onmenu is odd, but you can see in your original SB code you have used the same name OnMenu for the event subroutine AND a variable.

Code:
'Events Enabled
LDControls.MenuClicked = OnMenu
LDShapes.ShapeEvent=OnShapeEvent
GraphicsWindow.KeyDown=OnKeyDown
Controls.ButtonClicked=OnButtonClicked
LDShapes.SetShapeEvent(tb[0])
Controls.Texttyped=OnTextTyped
While "True"
  If OnMenu = "True" Then
...
Sub OnMenu 'Setup Menu
  OnMenu="True"
EndSub

The fix is probably use separate variable for variable and subroutine name in SB, or in the C# change to use the delegate function name (without the m_).
Code:
        LDControls.MenuClicked += _SmallBasicProgram.onmenu;
        LDShapes.ShapeEvent += _SmallBasicProgram.onshapeevent;
        GraphicsWindow.KeyDown += _SmallBasicProgram.onkeydown;
        Controls.ButtonClicked += _SmallBasicProgram.onbuttonclicked;
        LDShapes.SetShapeEvent(Primitive.GetArrayValue(tb, 0.0));
        Controls.TextTyped += _SmallBasicProgram.ontexttyped;

So, it does make sense!

If I didn't spot this, my next step would be to test a very simple SB event program and see what it looked like decompiled:

Code:
GraphicsWindow.MouseDown = OnMouseDown

Sub OnMouseDown
EndSub
[-] The following 1 user Likes litdev's post:
  • jrmrhrb00
Reply


Messages In This Thread
RE: Small Basic Program Conversion to C# - by z-s - 12-09-2024, 05:00 PM
RE: Small Basic Program Conversion to C# - by litdev - 12-09-2024, 08:03 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)