twinBASIC Update: December 12, 2021

Highlights include the File I/O system reaching feature-complete status, an updated twinBASIC roadmap, and experimental text encoding support.

twinBASIC Update: December 12, 2021

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.


Additional File System Features Implemented

Last week saw continuing work on the File System features of VBx, both in terms of language statements and standard library methods.  Here's an updated list of implemented features with newly implemented features from this week in bold:

Language Statements Implemented

  • Open (Binary / Random modes only)
  • Put
  • Get
  • Print
  • Seek
  • Write
  • Lock
  • Unlock
  • Input #
  • Name-As
  • Width #
  • Line Input #

VBA.FileSystem Library Members Implemented

  • FreeFile
  • EOF
  • LOF
  • FileAttr
  • Loc
  • Seek
  • Reset
  • FileLen
  • FileDateTime
  • GetAttr
  • SetAttr
  • MkDir
  • RmDir
  • ChDir
  • ChDrive
  • CurDir / CurDir$
  • FileCopy
  • Dir
  • Kill

File System Features Not Yet Implemented

The VBx file system portion of twinBASIC is now feature-complete!

However, Wayne has some twinBASIC-exclusive file system features on the development roadmap, including:

Customizable Text Encoding – Experimental

If you're not sure why this matters, please read this now-decades-old piece from Joel Spolsky: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Ever wonder about that mysterious Content-Type tag? You know, the one you’re supposed to put in HTML and you never quite know what it should be? Did you ever get an email from your friends in…

This feature is currently in the experimental stages.  Here's a quick sample from Wayne:

Open "Z:\unicodeTest.txt" For Output Encoding "utf-8 BOM" As #1
    Print #1, "Hello from twinBASIC! 😎"
Close #1

Dim myString As String
Open "Z:\unicodeTest.txt" For Input Encoding "utf-8 BOM" As #1
    Line Input #1, myString
Close #1

Debug.Print "FILE DATA: " & myString

The Encoding "utf-8 BOM" portion of the Open commands above is not valid VBx syntax.  That's the part that's new in twinBASIC.  And, in fact, the above code probably won't be valid twinBASIC syntax for long, either, as the "utf-8 BOM" string parameter will likely be replaced with an enumeration, such as Encoding.encUtf8.  Stay tuned!

Big File Support – On the Roadmap

Native VBx file handling breaks on all files larger than 4GB.

Wayne summarized the problem and highlighted the scope of a potential fix:

Currently, file positions are considered 32-bit wide and that limits the maximum allowed file size supported by VBx and tB.   There are several areas of the syntax that need to be tweaked, and of course several of the library functions will also need to be tweaked, or extended versions provided.

Wayne stated that he would look into implementing this in Q1 2022.

Go To Definition Now Works on Line Labels

Using the "Go to Definition" feature in VS Code, you can now jump directly to the line labeled MyLabel when you press [F12] on the code: GoTo MyLabel.  This is not something you can do in the VBA IDE.

Around the Web

twinBASIC 12-Month Roadmap Updated

Two days ago, Wayne updated the twinBASIC Roadmap to indicate which features have been implemented as well as which items are still on the to-do list.

The following items have been completed so far:

Forcing Windows to Update Your .EXE's Icon

Apparently, Windows Explorer caches icons embedded in .exe files.  So, if you change the icon of a compiled twinBASIC .exe project after you've already compiled it at least once, then Windows will continue showing the old icon.

Leave it to Wayne to know the command to force Windows to clear the Windows Explorer icon cache: ie4uinit -show.

Destructuring Assignment Support Requested

I'll admit, I had to look up what "Destructuring Assignment Support" meant, but it's basically a way to assign multiple results from a function to multiple variables on the left-hand-side of an expression.

You can sort of do this in VBA now by declaring a user-defined type (UDT) and passing that as the return type of a function, but it has its own limitations (and requires explicitly declaring the UDT).  

You can also sort of do this by returning an array as a Variant and assigning it to a Variant on the left-hand side of the expression.  This approach lacks type safety and other compile-time safety, such as matching the number of items on each side.

The shortcomings from both workarounds described above would be addressed if twinBASIC supported Vladimir Vissoultchev's (wqweto on GitHub) request:

There is some precedent for this type of syntax in VBx, as evidenced by the Mid statement.


Here are the updates from the past week.  You can also find this information by installing the twinBASIC VS Code extension and clicking on the Changelog tab of the extension page:

[v0.13.30, 11th December 2021]

[v0.13.29, 10th December 2021]

[v0.13.28, 10th December 2021]

  • fixed: terminating a debug session while stepping through code often caused a compiler-restart (64-bit only)
  • fixed: LSP bad JSON encoding for codeLens feature when an identifier contained a double-quote, causing LSP re-connection and IDE flickering [ ]

[v0.13.27, 10th December 2021]

[v0.13.26, 9th December 2021]

[v0.13.25, 8th December 2021]

[v0.13.24, 7th December 2021]

[v0.13.23, 7th December 2021]

[v0.13.22, 7th December 2021]

[v0.13.21, 6th December 2021]

[v0.13.20, 6th December 2021]

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