twinBASIC Update: July 22, 2024
Highlights include two blockbuster features that Access developers will instantly recognize: an Access-style report writer and a lightweight expression service.
![twinBASIC Update: July 22, 2024](/content/images/size/w2000/2024/07/twinBASIC-Weekly-Update-1--3.png)
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:
- Custom twinBASIC IDE Installation Guide
- twinBASIC Discord Server (chat about the project)
- twinBASIC Wiki (list of new features not in VBx)
- GitHub Issue Tracker (report bugs)
- twinBASIC/VBx LinkedIn Group
Highlights
There were no new releases to talk about in last week's twinBASIC Update.
If you've been following this project for awhile, you know that only happens for one of two reasons:
- There's significant upheaval in Wayne's personal life (moving houses, illness, or school breaks 😁)
- Wayne's got his head down working on something BIG
Luckily for everyone, last week was a case of the latter.
This week brings the release of two huge new features:
- Reports
- Expression Service
Each feature was big enough to warrant its own Discord server channel.
These new features are especially relevant to my Microsoft Access developer audience, as they are the closest thing to "Access-specific" features that we've seen so far in twinBASIC's young life.
Now, before anyone gets too excited, I don't think Wayne has any plans to achieve 100% backwards compatibility with Microsoft Access. In other words, don't expect to import your .accdb into twinBASIC anytime soon. That said, I do think achieving 100% feature parity–enhancing twinBASIC until it lets you do everything you can do in Access–is an attainable goal.
And adding these two new features is a huge step in that direction.
twinBASIC Expression Service Introduced
This week saw the introduction of a lightweight expression service in twinBASIC, marking a significant step forward in the language's capabilities. The new feature, available as of BETA 574, offers developers a flexible and simple way to evaluate expressions at runtime.
Wayne introduced the feature in Discord:
In it's simplest form, you can do this:
MsgBox Eval("41 + 1")
and you'll receive the answer to everything.
Key points from the discussion:
- The expression service is lightweight, adding only about 130KB to a typical build when used.
- It allows the use of nearly all standard library functions from the VBA namespace.
- Developers can customize support through implementing their own binders.
- The service offers similar compatibility to MS Access expression service, including features like
Iif
not evaluating both truth and false expressions. - Expressions can be compiled once and executed multiple times, improving performance in scenarios like report generation.
Public Function Eval(ByVal Expression As String) As Variant
With New TbExpressionService
.AddStdLibraryBinder()
Dim CompiledExpression As ITbExpression = .Compile(Expression)
Return CompiledExpression.Evaluate()
End With
End Function
- The service allows for custom binders, enabling developers to expose specific objects or functionality to the expression service.
- Security considerations are in place, with certain functions like
CreateObject
,GetObject
, andShell
disabled to prevent potential abuse. - The expression service is scope-aware, trying each binder in the order they were added.
- There are plans to potentially add a binder for "global" project scope in the future.
- Suggestions were made for future enhancements, including an
[EvaluateMember]
attribute and the ability to reference modules as objects for custom binders.
In conclusion, the introduction of the expression service in twinBASIC represents a significant advancement in the language's capabilities. While still in its early stages and not thoroughly tested, it provides developers with a powerful tool for dynamic expression evaluation, particularly useful in scenarios like report generation. The flexibility offered through custom binders and the similarity to MS Access's expression service make it a valuable addition to the twinBASIC ecosystem.
* NOTE: Claude-3.5-Sonnet-200k auto-generated this section as a recap of the discussion from the new Expression-Eval channel in the twinBASIC Discord server
For more about the expression service in Access and how it differs from traditional VBA code, check out this primer I wrote on the subject:
![](https://nolongerset.com/content/images/2020/10/goats-173940_1280.jpg)
twinBASIC Report Designer Update
This week saw significant progress in the development of twinBASIC's new report designer feature. The team addressed several issues and added new functionalities based on user feedback and comparisons with other reporting solutions.
Key points from the discussions:
- A new report designer was introduced in BETA 574, with some limitations and issues still to be addressed.
- Custom border functionality was added to the Label control in BETA 577, allowing independent control of size, padding, and color for each side.
- A new
CheckMark
control (initially namedPureCheckBox
) was introduced, offering a windowless checkbox suitable for data binding in reports. - Discussions around export functionality highlighted the importance of common formats like PDF, Excel, and CSV for business users.
- The team is considering how to implement export features, balancing between built-in functionality and potential third-party solutions.
- Users can now use the "Align to Grid" option in the report designer, similar to the form designer.
- There were comparisons made to other reporting solutions like ActiveReports, highlighting features that users find valuable.
Here's an example of the new custom border functionality for labels:
Label1.BorderStyle = vbCustomBorder
Label1.BorderTopWidth = 2
Label1.BorderTopColor = vbRed
Label1.BorderLeftWidth = 5
Label1.BorderLeftColor = vbBlue
The discussions this week revealed a strong focus on making the twinBASIC report designer both powerful and user-friendly. The team is actively incorporating user feedback and industry standards into the development process, aiming to create a reporting solution that meets the needs of modern business applications while maintaining compatibility with existing VB6 and Access reporting paradigms.
* NOTE: Claude-3.5-Sonnet-200k auto-generated this section as a recap of the discussion from the new Reports channel in the twinBASIC Discord server
Discord Chat Summary
* Auto-generated via Claude-3.5-Sonnet-200k on poe.com
General Channel Chat Recap
The twinBASIC project continues to make significant strides in enhancing its capabilities and user experience. This week saw several notable developments, including new control features, performance improvements, and discussions about language syntax and functionality.
Key points:
• New Label control enhancements were introduced in BETA 579, allowing for rotated text rendering. This feature is particularly useful for report generation.
• A QRCode control was added in BETA 580, based on @wqweto's VbQRCodeGen project. This control supports reports and data binding, expanding twinBASIC's capabilities for generating visual data.
• BETA 581 introduced simple gradient fills for Shape controls, further enhancing the visual customization options available to developers.
• The Shape gradient options were extended to work with reports in BETA 583, providing more flexibility in report design.
• Discussions about language syntax included the use of CType(Of)
for handling pointers, potentially simplifying code that previously required complex memory operations.
• There were conversations about improving Intellisense, particularly hiding the 'new' constructor method when working with interfaces to enhance fluent interfacing.
• The community discussed various approaches to initialization and constructor patterns, showcasing twinBASIC's flexibility in supporting different coding styles.
• A fundraising effort was initiated to upgrade the compilation server, aiming to reduce compilation times and accelerate twinBASIC development.
In conclusion, this week's discussions and updates demonstrate twinBASIC's ongoing evolution, with a focus on enhancing visual controls, improving language syntax, and optimizing performance. The addition of features like QR code generation and gradient fills shows a commitment to modernizing the language while maintaining compatibility with classic Visual Basic paradigms. The community's engagement in discussions about language design and the support for hardware upgrades highlight the collaborative nature of twinBASIC's development process.
Around the Web
Ask Hackaday: Should We Teach BASIC?
twinBASIC gets a shout-out in the comments section of the article below which discusses whether BASIC should be used to teach beginners, highlighting differing opinions on its simplicity and accessibility compared to modern languages like Python:
![](https://hackaday.com/wp-content/uploads/2024/07/basic.png)
Creating an Excel XLL with twinBASIC?
loquat opened an interesting issue over on the twinBASIC GitHub page asking how to use twinBASIC to develop an add-in for Excel that would allow you to call into the library via worksheet functions:
Excel automation addin is an ax dll to add user define formula functions which can call in worksheet.
which is different from VBA VBE addin as well as Com AddIn
If I understand the question correctly, I think this is more of a feature request than a bug report. Here's how I responded on GitHub:
I believe what you are looking for is how to create an XLL add-in.
If that's the case, I'd consider this a feature request rather than a bug report.
A few thoughts:
- This would be a great feature!
- This won't be a v1 feature.
- It may already be possible to create an Excel XLL given twinBASIC's current capabilities, but exposing and implementing the required features is beyond my level of technical skill (maybe @fafalone could assist?).
- There's an existing open-source .NET project that could be referenced for inspiration: ExcelDNA
Ultimately, twinBASIC may already support this feature, it's just that implementing it requires a good bit of low-level C and C++ knowledge.
I will be following this thread with great interest.
Changelog
Here are the updates from the past week. You can also find this information by visiting the GitHub twinBASIC Releases page.
AI-Generated Changelog Summary
* Auto-generated via Claude-3.5-Sonnet, sorted in order of its opinion of "most impactful changes."
Here's a concise summary of the notable updates in twinBASIC:
-
Reports Support: Added experimental support for reports with a visual designer, including bound and unbound reports, and new features like Label.DataFieldAggregate for running sums.
-
Expression Evaluation: Introduced TbExpressionService class and Eval() helper for simplified expression evaluation, enhancing report functionality with support for VBx DataReport placeholders.
-
New Controls: Added CheckMark (formerly PureCheckBox) for databinding in reports, and QRCode control based on wqweto's VbQRCodegen project.
-
Enhanced Styling Options: Implemented Label.Angle property for rotated text, custom border options for Labels, and gradient fill styles (vbGradientNS and vbGradientWE) for Shapes.
-
Image Improvements: Added experimental Image.StretchMode property with Lanczos, Bicubic, and Bilinear options for enhanced image rendering.
WARNING: The following issues are present in BETA builds 546 - 584 (the latest build as of publication):
- there are known memory leaks in these versions, so memory usage will be higher than normal
BETA 574
- added: experimental support for Reports, with visual designer, supporting bound and unbound reports [comissioned work]
- added: TbExpressionService class, and helper Eval() to simplify usage [comissioned work]
- added: Label.DataFieldAggregate experimental property for offering running-sum in reports
- NOTE: REPORTS CURRENTLY LIMITED TO A4 PAPER SIZE ONLY FOR PRINTING
BETA 575
- fixed: (regressions) several form/report designer glitches introduced in the last release
- improved: report Label expression evaluation errors now show as '#Error' at runtime
- improved: report Label captions now support the VBx DataReport placeholders %p, %P, %d, %D, %t, %T, %i
BETA 576
- fixed: (regression) PtrSafe errors in VB.Report [ TecMan, discord ]
- improved: Form/Report designer now keeps many menu and toolbar options available when focus has moved to the PROPERTIES panel
- fixed: some further form/report designer issues, particularly around scrolling and zooming
BETA 577
- added: PureCheckBox control - a windowless check box, useful for databinding in reports
- added: Label.BorderStyle option of vbCustomBorder, and Label.CustomBorderOptions property offering customized borders (Size/Color/Padding for Left/Top/Right/Bottom)
- fixed: some issues around COM error propagation [ Tecman, discord ]
BETA 578
- changed: 'PureCheckBox' now renamed to 'CheckMark' [ Krool, discord ]
- updated: 'Sample 0. Reports' to show CheckMark bound to a data-expression
BETA 579
- improved: changing BorderCustomOptions properties at runtime is now supported
- added: Label.Angle property (double, in degrees). Label events currently disabled when Angle <> 0 [ commissioned work ]
- fixed: CheckMark.Click event not firing
- fixed: IDE designer grid options not always kept in sync when switching between designers
BETA 580
- added: QRCode control, MIT licenced, based on wqweto's awesome VbQRCodegen project [ thanks wqweto! ]
- updated: 'Sample 0 Reports' to include data-bound QRCode example
BETA 581
- added: Shape.FillStyle vbGradientNS and vbGradientWE plus Shape.FillColorAlt for applying simple gradients to GDI shapes [ comissioned work ]
BETA 582
- changed: Shape.FillStyle new gradient options currently ignored for reports due to incompatibility
BETA 583
- fixed: Shape vbGradientNS/vbGradientWE now also working with reports
BETA 584
- added: Image.StretchMode experimental property, offering Lanczos/Bicubic/Bilinear options, defaults to GDI Halftone [ commissioned work ]