twinBASIC Update: August 13, 2023
Highlights include brand new add-in support for the twinBASIC IDE, plus a short Q&A about setting an application icon in twinBASIC.
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:
- Custom twinBASIC IDE Installation Guide
- GitHub Issue Tracker (report bugs)
- twinBASIC Discord Server (chat about the project)
- twinBASIC/VBx LinkedIn Group
Highlights
twinBASIC IDE Extensibility: Create Add-ins for the tB IDE
This one caught me completely by surprise.
I always assumed Wayne would add this feature at some point. I just didn't think "some point" would be prior to the v1.0 release. Or that he could put together a working proof-of-concept so quickly.
Wayne announced the feature in a new Discord #addins channel (emphasis mine):
.Welcome to #addins! Details to follow.
For now, check out Sample 10 in BETA 372. Once you've built an addin, you need to put the DLL in the newaddins\win32
oraddins\win64
folder that you'll find alongside the usual IDE folders (next to 'twinBASIC.exe' etc)
This is more for laying the foundations. You can currently create toolbar buttons, write to the debug console, execute code, and that sort of thing. much more to come!
Wayne soon followed up the announcement with some technical details:
All tb Add-ins run in their own dedicated thread inside the compiler background process (not inside the IDE process itself).
If you want to show a Windows form, you'll have to display it modally for now.
TheOnProjectLoaded
event is synchronized so that multiple add-ins don't trip over themselves. Generally, this is the event you'll use for adding custom buttons and menus to the IDE. Currently, the only way to unload add-ins is to restart the compiler. You can hold down the shift key when opening a project (or restarting the compiler) to prevent Add-ins from being loaded (edited)
Using own forms is tricky at present since the compiler process is separate to the IDE process. Either set them toTopMost
or you can try changing the form hwnd owner to the IDE hwnd (which is available viaHost.IDEWindowHandle
)
In future, you'll be able to create your own HTML based panes inside the IDE
The plan is that unit test integration will be provided for by an open source tB addin.
Two updates later, in BETA 374, Wayne already added several improvements to the addin extensibility feature:
- DebugConsole.SetFocus method
- Host.ActiveEditors (collection of Editor objects, zero-based)
- Editor.Path property (read-only)
- Editor.Type property (read-only)
Editor.SetFocus method - Editor.Close method
- Editor.Save method
- CodeEditor.SelectedText property (read/write)
- CodeEditor.Text property (read/write)
- CodeEditor.ExecuteMonacoCommand method (e.g. 'actions.find')
Discord Chat Summary
* Auto-generated via Claude-2-100k on poe.com
Here are the key highlights from the Discord conversation about the twinBASIC programming language:
- twinBASIC is a new BASIC language that aims to be compatible with Visual Basic 6 while adding many new features. It is under active development.
- The IDE is lightweight and fast compared to VSCode/Visual Studio. It has a built-in form designer that is better than VS at this early beta stage.
- There is discussion around improving project templates, with guidance from the developer on using special placeholder GUIDs that get auto-generated when creating a project.
- A large set of VBCCR controls was ported to support 64-bit twinBASIC, allowing complex GUIs. Property page support is hoped to be added soon.
- There are some obscure VB6 bugs being uncovered relating to conditional compilation of events and controls. Workarounds are being devised.
- The community is developing utility libraries like tbShellLib to wrap common APIs not provided by default in twinBASIC.
- Large VB6 projects (100k+ LOC) are being ported over, uncovering issues like problems with deserializing forms and controls in compiled exes.
- There are requests for features like optional stripping of relocations from exes, proper alias support, and fixes for Err.Raise behavior.
Overall, rapid progress is being made and hopes are high that twinBASIC can someday compete with modern languages given its native compilation, VB6 compatibility, simple syntax, and visual designer.
[Follow-up prompt:] Can you provide more details about the utility library tbShellLib and its purpose?
Here are some more details about the tbShellLib utility library:
- tbShellLib is a package maintained by the Discord user fafalone. It contains declarations for many common Windows APIs not provided by default in twinBASIC.
- For example, it declares Windows data types like HANDLE and complex structures like PROCESS_INFORMATION that are needed to call certain APIs.
- HANDLE is declared as LongPtr since twinBASIC lacks alias support currently. Enums like BOOL and DWORD are declared to mimic their definitions in C/C++ headers.
- The goal is to make it easier to call Windows APIs by wrapping the necessary declarations, rather than having to declare them manually.
- tbShellLib covers a substantial portion of APIs that VB developers would commonly need to do things like work with processes, files, the registry etc.
- It is distributed as source code that can simply be imported into a twinBASIC project, rather than a binary dependency.
- The project is open source on GitHub for community contributions. As twinBASIC matures, APIs from tbShellLib may get incorporated into the core language.
Overall, it shows twinBASIC's potential to be extended for systems programming via API declarations, which was not practical in VB6.
Around the Web
Setting the Application Icon
In Discord, user Ishalom asks, "Where do I set the application icon?"
Fafalone responds,
In the Project Explorer, under the Resources folder, there's a subfolder named 'ICON' (or if not you can create one)... the one alphabetically first is used for the icon. We do need a better system for it I think.
Changelog
Here are the updates from the past week. You can also find this information by visiting the GitHub twinBASIC Releases page.
WARNING: The following issue is present in BETA builds 202 - 374 (the latest build as of publication):
- there are known memory leaks in these versions, so memory usage will be higher than normal
BETA 369
- improved: faster general IDE performance (intellisense, syntax highlighting, error reporting) for many projects, particularly those containing many forms/UserControls/AXs
BETA 370
- fixed: (regression in BETA 369) use of ActiveX controls were causing a hard crash at design time
- improved: template '_Standard EXE (plus VBCCR)' has been updated to use Krools 64-bit compatible package of VBCCR
- removed: redundant
code-workspace
files from the IDE deployment that are no longer used
BETA 371
- fixed: IDE packages list search feature was not working correctly [ Krool, discord ]
- fixed: IDE packages list was not alphabetically ordered [ Krool, discord ]
- fixed: some Implements-Via edge cases causing 'overloaded properties not allowed' errors in UserControls in some instances [ nextKast, discord ]
- improved: error diagnostic for 'overloaded properties not allowed' now includes the property name for clarity
- fixed: (regression since BETA 366) edge cases around parsing of line continuators [ https://github.com//issues/1652 ]
BETA 372
- added: initial support for creating and using ADDINs for the twinBASIC IDE [ see Sample 10 and discord ]
BETA 373
- added: IDE menu option
Window
>Reset Layout...
for resetting the IDE panel layout data - fixed: (regression) PROBLEMS panel would sometimes get stuck, unable to resize and toggle the content [ Tecman, private ]
- fixed: (regression) IDE would often add square brackets around enum values inappropriately [ fafalone, discord ]
- fixed: App.LastBuildPath would raise an error in built executables. now returns an empty string instead [ https://github.com//issues/1641 ]
BETA 374
- added: (addin extensibility) DebugConsole.SetFocus method
- added: (addin extensibility) Host.ActiveEditors (collection of Editor objects, zero-based)
- added: (addin extensibility) Editor.Path property (read-only)
- added: (addin extensibility) Editor.Type property (read-only)
- added: (addin extensibility) Editor.SetFocus method
- added: (addin extensibility) Editor.Close method
- added: (addin extensibility) Editor.Save method
- added: (addin extensibility) CodeEditor.SelectedText property (read/write)
- added: (addin extensibility) CodeEditor.Text property (read/write)
- added: (addin extensibility) CodeEditor.ExecuteMonacoCommand method (e.g. 'actions.find')