twinBASIC Update: November 12, 2024

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 Monday week, 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, please leave a comment below.

Here are some links to get involved with the project:


Highlights

Next Release on Friday?

The latest word from Wayne is that the next big twinBASIC release is due this Friday, November 15.

According to Wayne, that update "should fix a lot of [event-related] issues, as events will more strictly adhere to VBx behaviours."

Exporting .TLB Files from twinBASIC EXEs

Did you know you can export a type library (.tlb) file from a twinBASIC application using 7zip?

No? Don't feel bad. Wayne Phillips didn't know about that either.

Here's an excerpt from the related conversation in Discord:

  • [deletedewd] I've tried this approach of writing interfaces in an ActiveX DLL then testing it in VB6, seems to work great so far! Too bad that API declarations aren't exported in the ActiveX DLL as well, then it would be a complete TypeLib replacement!lasses in the ActiveX DLL, only modules with Interface declarations, don't need registry clutter with unused ProgId's from public classes, haha!
  • [waynephillipsea] We actually create a temporary TLB file as part of the build process before importing it into the EXE/DLL. We could easily add an option to retain it as an extra artifact of the build process
  • [tony.y94] TLB is in EXE resource TYPELIB\1, use 7-zip to extract then rename it to *.tlb
  • [waynephillipsea] Nice, didn't know you could do that with 7zip

What does all this mean? To be honest–I'm not 100% sure, so I asked Claude-3.5-Sonnet to summarize the discussion and what it means:


Here's a summary of the discussion about extracting type libraries from twinBASIC builds using 7-Zip:

Background:
The conversation revealed that twinBASIC creates temporary type library (TLB) files during the build process before importing them into the EXE/DLL. While twinBASIC doesn't yet have direct TLB export functionality, there's a workaround using 7-Zip to extract these embedded type libraries.

Step-by-step instructions:

  1. Locate your compiled twinBASIC EXE/DLL file
  2. Open the file with 7-Zip
  3. Navigate to the TYPELIB\1 resource within the file
  4. Extract this resource
  5. Rename the extracted file with a .tlb extension

Why someone might want to do this:

  • To examine the type library information generated by twinBASIC
  • To use the type library in other development tools or environments
  • For debugging interface definitions
  • To verify type library generation is working as expected

Additional notes:

  • Resource Hacker can also be used as an alternative to 7-Zip for this process
  • Wayne Phillips mentioned they might add an option to retain the TLB as an extra artifact during the build process in the future
  • This technique also works for viewing string tables inside DLLs directly with 7-Zip without needing additional resource editing tools

This capability is particularly useful for developers working on COM interop scenarios or those who need to verify the interface definitions being generated by twinBASIC.


2024 Project Recap

I've been preparing for my upcoming twinBASIC presentation at Oxford next week (tickets still available here!), and as part of my preparation, I wanted a good recap of the major features and news surrounding twinBASIC from the past year.

To get that, I fed the entire twinBASIC Discord chat history into the Gemini-1.5-Flash-1M chatbot on Poe.com. This LLM from Google has a 1 million token context window, so it easily handled every word from every discussion about twinBASIC in 2024.

Here are the results:


The twinBASIC Discord general channel's 2024 logs reveal several features and improvements that generated significant excitement within the community. Here's a breakdown, categorized for clarity:

I. Core Language Enhancements:

  • Static Library Support (BETA 425): The ability to link static libraries (.lib, .obj) directly into executables was a highly anticipated feature, enabling the inclusion of pre-compiled C/C++ code without external DLL dependencies. The example of statically linking SQLite generated considerable enthusiasm. Subsequent discussions focused on refining this feature, including support for various calling conventions and dependency management.

  • Implicit Conversion Warnings (BETA 556): The introduction of compiler warnings (TB0018, TB0019, TB0020) for implicit type conversions, mimicking Option Strict in VB.NET, was well-received. This feature aimed to improve code quality and prevent subtle bugs arising from implicit type coercion, particularly relevant for generics. Further refinements and adjustments to these warnings were discussed throughout the year.

  • Function Pointers (Delegates) (BETA 616): The addition of function pointer types (delegate syntax) marked a significant step in enhancing the language's capabilities for low-level programming and interoperability with C/C++. Discussions centered on refining the syntax, handling edge cases, and improving type safety. The ability to use delegates with AddressOf on class members was also a key improvement.

  • CType(Of T) Conversion (BETA 556): This function provided a more robust and explicit way to perform type conversions, particularly useful for avoiding implicit type conversions and enhancing type safety. The ability to use CType with pointers to UDTs for direct memory manipulation was a significant highlight.

II. IDE Enhancements:

  • Real OS Title Bar (BETA 438): The ability to use a native operating system title bar instead of the custom one was a highly requested feature, significantly improving the IDE's integration with the Windows environment.

  • Customizable Keyboard Shortcuts (BETA 495): The introduction of a fully customizable keyboard shortcut system was met with much enthusiasm. The ability to assign any shortcut to any IDE command offered greater flexibility and personalization.

  • Improved Project Explorer (BETA 547): The introduction of an "object view" mode in the Project Explorer, providing a type-based rather than file-based view of project components, was a significant UI enhancement. This feature aimed to improve navigation and organization, particularly for larger projects.

  • Report Designer (BETA 574): The addition of an experimental report designer with support for bound and unbound reports, expression evaluation, and various controls (QR codes, gradients) was a major feature addition. The visual report designer and data binding capabilities generated considerable excitement.

  • Form Engine Rewrite (BETA 593): A major rewrite of the form engine significantly improved performance, stability, and compatibility with VB6 forms. This was a substantial undertaking that addressed numerous long-standing issues.

III. ActiveX/UserControl Improvements:

  • ActiveX Control Extender Improvements: Numerous bug fixes and performance improvements related to ActiveX controls and UserControls throughout the year were welcomed by the community. The ability to dynamically add built-in controls, while not yet fully implemented for UserControls, was a significant step forward.

  • MDI Form Support (BETA 537): The long-awaited addition of MDI (Multiple Document Interface) form support was a major milestone, enabling the creation of applications with multiple, dockable child windows.

The overall sentiment throughout the year was one of excitement and anticipation for the upcoming v1 release. The community actively participated in identifying and reporting bugs, suggesting improvements, and contributing to the project through add-ins and other contributions. The strong focus on backwards compatibility with VB6, combined with the introduction of modern features and a responsive development process, fueled the enthusiasm.


Discord Chat Summary

* Auto-generated via Claude-3.5-Sonnet-200k on poe.com

Here's a summary of the key discussions in the twinBASIC Discord general channel from November 2-11, 2024:

The past week saw active discussions about twinBASIC's development and compatibility features, with several notable points emerging:

  • A major update is planned for release on Friday, November 15th, which is expected to address several current issues and bugs, particularly around event handling and ActiveX control behaviors.

  • Key discussions focused on:

    • Interface implementations and delegate procedures, with detailed examples of proper vtable handling and memory management
    • Type Library (TLB) compatibility across 32-bit and 64-bit environments, including discussions about SYSKIND settings and platform dependencies
    • Reference counting behavior for interface pointers within User Defined Types (UDTs)
    • Proper threading implementations and COM marshaling techniques for multi-threaded applications
    • Project export functionality and source code management integration with Git
  • Several bug fixes and improvements were identified:

    • A fix for compiler crashes related to delegate procedure definitions
    • Improved handling of ListSubItems in ListView controls
    • Better error handling for interface pointer reference counting
    • Planned warning system for SYSKIND mismatches in TLB references
  • Comparisons to VB6 revealed some key differences in debugging behavior:

    • twinBASIC's debugger maintains state between runs unless explicitly reset
    • The IDE requires using the compiler restart button to fully reset the debugging environment
    • Some VB6 behaviors around COM object lifecycle management needed additional handling in twinBASIC

The week's discussions highlighted twinBASIC's continued evolution toward providing robust compatibility with legacy VB6 code while offering modern development features and improved type safety. The upcoming release appears focused on addressing core stability issues and improving the development experience.

Around the Web

Simple Video Player Control

Over on the Discord show-and-tell channel, fafalone posted a sneak peek of his latest project currently in development:

Here's a sneak preview of my upcoming video control. Full release will be after I make an equivalent VB6 version, but the original tB version is working.
This is a very simple Media Foundation control based on the IMFPMediaPlayer interface, which is much easier to use than the nightmare IMFMediaEngine method MS tells you to use, which unlike this won't work on Windows 7.
All the player features in the picture work; you can drag the sliders to change position and volume.
The nanosec interval -> 00:00:00 formatting function was lifted from -Franky-'s IMFMediaEngine example, thanks to him for that.

Changelog

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.

No new releases this week.