twinBASIC Update: November 13, 2022

Highlights include drag and drop support, an innovative IDE feature known as "Type Hints", and a proof-of-concept twinBASIC multithreading project.

twinBASIC Update: November 13, 2022

On April 23, 2021, I helped Wayne Phillips introduce the world to twinBASIC at the Access DevCon Vienna conference.  I boldly predicted that twinBASIC (along with the Monaco editor) would replace VBA and its outdated development environment by 2025.  With that goal in mind, this weekly update is my attempt to keep the project fresh in the minds of the VBA development community.

Every Sunday, I will be providing updates on the status of the project, linking to new articles discussing twinBASIC, and generally trying to increase engagement with the project.  If you come across items that should be included here, tweet me @NoLongerSet or email me at mike at nolongerset dot com.

Here are some links to get involved with the project:


Drag and Drop Support Added

As of BETA 173, the properties, methods, and events needed to support drag-and-drop were implemented on all controls.  This includes:

  • .DragMode, .DragIcon properties
  • .Drag method
  • .DragOver, .DragDrop events

Type Hints

I'm not sure if any other programming languages support this, but this is a pretty nifty development environment feature.  Here's the explanation from Wayne:

BETA 175 introduces TypeHints that allow us to offer a hint to the IDE as to the real datatype in situations where the definition of a parameter is more generically defined (e.g. a Variant, or a Long type that is really an enumeration).  This is needed to prevent breaking backwards-compatibility of a procedure signature (ABI), but still allowing us to refine the datatype for intellisense purposes.  

Let's look at an example from the VB library:
Step 1. Add the TypeHint Attribute to the Procedure Declaration
Note the new attribute syntax in the above function definition, [ TypeHint (DragConstants) ]
Step 2. Calling Code Now Shows More Useful IntelliSense Options

In the above screenshots, the Action parameter is defined as a Variant.  In VBx, this means you would get no IntelliSense.  However, there are times when you are forced to define a parameter as a Variant–such as if you need to accept Null values.

With the new TypeHint feature, you can tell IntelliSense what the function is expecting in most situations, even if the actual definition is set to something more generic (like Variant or Object).

App.Title Can Now Be Set at Runtime

Implented as of BETA 174.

New GUI Properties, Methods, and Events Implemented

Listed below are all the newly implemented form and control properties, methods, and events:

  • Form.ScaleMode, .ScaleLeft, .ScaleTop, .ScaleWidth, .ScaleMode, .ScaleX, .ScaleY
  • PictureBox.ScaleHeight, .ScaleLeft, .ScaleTop, .ScaleWidth, .ScaleMode, .ScaleX, .ScaleY
  • {ALLCONTROLS}.DragMode, .DragIcon
  • {ALLCONTROLS}.Drag method
  • {ALLCONTROLS}.DragOver, .DragDrop events
  • Form.Move method (fixed)

The full list of GUI items yet to be implemented is available here.

Around the Web

Simple Demo of MultiThreading in twinBASIC

From the very beginning, twinBASIC has supported multithreading.

That said, there is no twinBASIC language syntax that supports multithreading (such as the Async and Await keywords in VB.NET).  At least not yet.  Such support is on the roadmap for early next year (2023).

In the meantime, you can use a handful of Windows API calls (CreateThread, et al.) to implement "manual" multithreading in twinBASIC.  To showcase this approach, fafalone posted a proof-of-concept project on GitHub: ThreadTest.

Extremely simple demo of multithreading in twinBASIC

Normally, when you call MsgBox, code execution stops until you respond to it. In this demo, you'll see the following line continues and updates the label, before we decide to manually wait for it.


Here are the updates from the past week.  You can also find this information by visiting the GitHub twinBASIC Releases page.

Releases · WaynePhillipsEA/twinbasic
Contribute to WaynePhillipsEA/twinbasic development by creating an account on GitHub.

BETA 170

  • fixed: control anchor properties not working correctly in compiled builds when a form has a menu [ ]
  • fixed: [ArrayBoundsCheck(False)] on Win64 could cause a crash due to bad codegen [ wqweto, private ]
  • improved: minor performance improvements for accessing array elements with [ArrayBoundsCheck(False)] and fixed-length arrays
  • improved: variables panel entries are now sorted alphabetically

BETA 171

  • added: support for Form.ScaleMode / Form.ScaleX / Form.ScaleY
  • added: support for PictureBox.ScaleMode / PictureBox.ScaleX / PictureBox.ScaleY
  • fixed: Form.DrawWidth and PictureBox.DrawWidth are now scaled with DPI
  • fixed: (regression) DriveListBox crashing in Property Let ListIndex
  • improved: arrays were sometimes ordered incorrectly in the LOCALS IDE panel [ FullValueRider, discord]
  • improved: tweaked IDE LOCALS panel alignment of variable name & type [ rexxitall, discord ]
  • added: project setting 'Force Dpi Awareness At Startup', defaulting to 'PER_MONITOR_DPI_AWARE'
  • fixed: GetSetting/DeleteSetting not handling Optional Missing args properly [ ]

BETA 172

  • fixed: (regression) IDE crash on Win7

BETA 173

  • fixed: clicking on the form area no longer takes focus away from child controls, to match VBx
  • added: {ALLCONTROLS}.DragMode support
  • added: {ALLCONTROLS}.DragIcon support
  • added: {ALLCONTROLS}.DragOver event support
  • added: {ALLCONTROLS}.DragDrop event support
  • added: {ALLCONTROLS}.Drag method support

BETA 174

  • fixed: missing Form.Move method [ ]
  • improved: (IDE) code event selector drop down lists are now alphabetically sorted [ fafalone, discord ]
  • improved: VBP import log now includes warnings for controls that have been converted to PictureBox [ fafalone, discord ]
  • fixed: App.Title property can now be set at runtime, and now works inconjunction with AppActivate [ ]

BETA 175

  • added: support for [TypeHint(dataType)] attribute support for parameters, allowing for enhancing IDE intellisense without affecting ABI
  • improved: enhanced methods in standard libraries with TypeHints; {ALLCONTROLS}.Drag, Global.LoadResPicture, Global.LoadPicture, Screen.MousePointer, Clipboard.GetText, Clipboard.GetFormat, Clipboard.SetText

All original code samples by Mike Wolfe are licensed under CC BY 4.0