twinBASIC Update: May 22, 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:
- Custom twinBASIC IDE Installation Guide (NOTE: the twinBASIC VSCode extension is under a feature freeze until 2023)
- GitHub Issue Tracker (report bugs)
- twinBASIC Discord Server (chat about the project)
Highlights
Screen Object Added
The Screen object from VB6 is now available in limited form within twinBASIC. Currently, it only supports the following properties/methods:
- Fonts
- FontCount
Bug Fixes
There were several noteworthy bug fixes, both in the IDE and the language itself, including:
- Save Project dialog now warns if you are about to overwrite an existing project file
- Setting breakpoints is now more reliable
- Date$ and Time$ now return the correct invariant formats (MM-DD-YYYY and HH:NN:SS)
In reading through the GitHub issues, it's clear that user @KarlSevenSeven is working on converting a large VB6 project to run in twinBASIC. He's uncovered several edge and corner cases that Wayne has been playing Whac-A-Mole with this past week.
Every bug fixed is one step closer to 100% backward compatibility.
Around the Web
Updated Attribute Syntax
The current attribute syntax (e.g., [ Description ("this does foo") ]
) is being deprecated in favor of a different syntax that addresses a few shortcomings of the original, namely:
- Square brackets already have multiple meanings in VBx
- Awkward syntax for inline attributes
- Incompatible with enum members (this alone was probably a deal-breaker for the original syntax)
The new syntax is: @Description("this does foo")
@
: the literal "at" characterDescription
: the attribute name("this does foo")
: attribute arguments (optional for boolean attributes)
You can read Wayne's announcement on Github.
Procedure Execution Order Differs Between Native (Compiled) Code and (intermediate language) P-Code
While Wayne has not yet devised a solution to this problem, I found its mere existence to be rather unexpected:
So in VB6, with the following code you will see different ordering of the execution of procedures depending on whether you compile to Native Code or PCode.
Module MyModule
Public g_Log As String
Public Sub Test()
Dim LHS As New MyClass
Dim RHS As New MyClass2
Set LHS.Target = RHS.Clone
MsgBox g_Log
End Sub
End Module
Class MyClass
Public Sub Class_Initialize()
g_Log = g_Log & vbCrLf & "MyClass.Class_Initialize was called"
End Sub
Public Property Set Target(ByVal Value As MyClass2)
g_Log = g_Log & vbCrLf & "MyClass.Target was called"
End Property
End Class
Class MyClass2
Public Sub Class_Initialize()
g_Log = g_Log & vbCrLf & "MyClass2.Class_Initialize was called"
End Sub
Public Function Clone() As MyClass2
g_Log = g_Log & vbCrLf & "MyClass2.Clone was called"
End Function
End Class
Wayne ends with the following thought:
Unfortunately, for ultimate compatibility, we're probably going to need a switch to simulate the different compilation behaviours. 😢
Tangents and Rabbit Holes
This item is just a bit off-topic...
Did anyone ever point out a misstatement you made and–instead of acknowledging said mistake and moving on–you invented an alternate ending for an 85-year-old beloved children's movie which you then tied in to a completely unrelated cult classic movie released 62 years later?
Ummm....yeah....me neither.
Unless you count my response to Ben Clothier's comment from last week's twinBASIC update:
Can you please walk me through the scene where Ms. White hustled a cottage from the seven dwarves? I seemed to have missed that scene.
Changelog
Here are the updates from the past week. You can also find this information by visiting the GitHub twinBASIC IDE issues page.
NOTE: Development of the twinBASIC VSCode extension is paused until 2023 so that efforts can be focused on the new IDE.
BETA 46
BETA 46 is now available:
https://www.twinbasic.com/downloads/twinBASIC_IDE_BETA_46.zip
- fixed: a form class being declared as Private causes linkage errors (runtime messages of 9508/9402) [ https://github.com/Async execution works in IDE, not from VBA #864 ]
- fixed: panels in the bottom vertical section shouldn't have collapse/expand toggle icons [ https://github.com/twinBASIC IDE -- BETA RELEASE #772#issuecomment-1133589694 ]
- improved: you can now click on empty space in a tree panel to focus the tree, allowing for keyboard entry
- fixed: intellisense issue where the enter key would not clear the intellisense window at the end of a line following a space and no selection
BETA 45
BETA 45 is now available:
https://www.twinbasic.com/downloads/twinBASIC_IDE_BETA_45.zip
- fixed: setting breakpoints is now more reliable
- fixed: Set-statement with LHS of byref-Variant pointing to an empty Variant was failing [ https://github.com/Tests fail when passing a whole paramarray but succeed when passing a paramarray item #860#issuecomment-1132630645 ]
- fixed: internal IUnknown methods of __QueryInterface/__AddRef/__Release etc sometimes showing in intellisense
- fixed: intellisense not showing base members of extended interfaces [ https://github.com/Change NotDispatchable keyword into an attribute #806#issuecomment-1122563243 ]
- fixed: code editor combo drop-down selecters now work correctly with extended interfaces [ https://github.com/Change NotDispatchable keyword into an attribute #806#issuecomment-1122563243 ]
BETA 44
BETA 44 is now available:
https://www.twinbasic.com/downloads/twinBASIC_IDE_BETA_44.zip
- fixed: For-Each handling of variant arrays that don't have the VARTYPE explicitly set on the SAFEARRAY [ https://github.com/Tests fail when passing a whole paramarray but succeed when passing a paramarray item #860 ]
- fixed: Byref-Variant assignments involving arrays [ https://github.com/Can't assign array #859 ]
BETA 43
BETA 43 is now available:
https://www.twinbasic.com/downloads/twinBASIC_IDE_BETA_43.zip
- fixed: Rnd() initial seed was not being set in built EXE/DLL files [ https://github.com/Rnd problem #856 ]
- improved: global variables code-gen errors are to be ignored until the global variables get initialized [ https://github.com/Spurious error messages in debug console #852 ]
- fixed: global initializers/terminators not being executed in DLL builds [ jpbro ]
BETA 42
BETA 42 is now available:
https://www.twinbasic.com/downloads/twinBASIC_IDE_BETA_42.zip
- fixed: passing an object-type array element to a ByRef parameter with an inexact matching type (e.g. Object/Variant), caused an array lock to be left open [ https://github.com/Redim Preserve: Memory is locked #855 ]
- top-level menu disappears when moving back to the top-level menu header [ https://github.com/twinBASIC IDE -- BETA RELEASE #772#issuecomment-1130158068 ]
BETA 41
BETA 41 is now available:
https://www.twinbasic.com/downloads/twinBASIC_IDE_BETA_41.zip
- fixed: Date$ and Time$ now return the correct invariant formats (MM-DD-YYYY and HH:NN:SS) [ https://github.com/Date$ and Time$ formats need to be invariant #846 ]
- fixed: trying to cast an ActiveX control from the host container Object to the real type was failing [ https://github.com/Type mismatch when assigning an ActiveX control to a variable #848 ]
- fixed: ActiveX controls were exposing all internal members, e.g. the inner controls and inherited UserControl members [ https://github.com/ActiveX control seem to leak members that should be private #849 ]
- fixed: the Save Project dialog now warns if you are about to overwrite an existing project file [ https://github.com/No overwrite warning #850 ]
- fixed: ReDim-Variant[ByRef] bug causing illegal SAFEARRAY initialization [ https://github.com/Array assignment problem #851 ]
- improved: IDE recent projects list was cached at startup rather than being live
- improved: panel collapse toggling now requires clicking on the expand/collapse icon, not the whole title bar [ https://github.com/IDE panel not resizable when adjacent panel is collapsed #853#issuecomment-1130004050 ]
BETA 40
BETA 40 is now available:
https://www.twinbasic.com/downloads/twinBASIC_IDE_BETA_40.zip
- fixed: statements entered between an opening
Select Case
and before the firstCase
statement are now not allowed [ https://github.com/twinBasic executes code between Select Case and first case statement #844 ] - added: Global.LoadResIdList(resourceType) function, returning an array of names/ids contained within a resource folder, see examples in WebView2 samples (CopyResourcesFolderContentsToLocalPath function)
- added: Screen object, currently only offering Fonts, and FontCount member
- fixed: IDE menu clicks vs mousedown/up behaviour [ https://github.com/twinBASIC IDE -- BETA RELEASE #772#issuecomment-1127692147 ]