.NET Wrapper for the ThinBasic Scripting Engine
Embed ThinBasic scripts in .NET apps, inject host constants and keywords, parse callback arguments, work with arrays, isolation, hash tables, and module classes — all through a clean C# API.
Init the engine, run .tbasic buffers or files, and release cleanly from any .NET host.
Register managed delegates as ThinBasic symbols — numbers, strings, and full parser callbacks.
Inject constants and variables from the host; read and change script-side state at runtime.
Inspect arrays, redim, and use direct variable pointers for high-performance host integration.
InitIsolated extracts modules into a dedicated directory — ideal for sandboxed hosts.
Register module classes with methods/properties, plus thinCore string hash table APIs.
High-level coverage of thinCore.dll
Init · inject host symbols · run script · release
using ThinBasic.NET.Core;
int h = Thinbasic.Init(0, 0, "thinbasic");
if (h != 0)
{
Console.WriteLine("Init failed: " + Thinbasic.GetLastError());
return;
}
Thinbasic.AddEquate("%HOST_EQ", string.Empty, 7, (int)Enums.EquateType.Number);
int hostCalls = 0;
Thinbasic.LoadSymbol("HostFlag", () => hostCalls++, Enums.ForceOverWrite);
Thinbasic.LoadSymbol("HostNum", () => 123.5, Enums.ForceOverWrite);
Thinbasic.LoadSymbol("HostStr$", () => Thinbasic.AllocReturnString("hello"), Enums.ForceOverWrite);
string script = File.ReadAllText(@"Sample\test.tbasic", Encoding.UTF8);
int result = Thinbasic.Run(
h, script, (int)Enums.BufferType.IsScript,
0, 0, 0, 0,
(int)Enums.CallingProgram.Console, 0);
int lastError = Thinbasic.GetLastError();
Thinbasic.Release(h);
Thinbasic.ClearSymbolCallbacks();
Thinbasic.LoadSymbol("HostAdd", () =>
{
if (Thinbasic.CheckOpenParensMandatory() == 0) return 0;
Thinbasic.ParseNumber(out double a);
if (Thinbasic.CheckCommaMandatory() == 0) return 0;
Thinbasic.ParseNumber(out double b);
if (Thinbasic.CheckCloseParensMandatory() == 0) return 0;
return a + b;
}, Enums.ForceOverWrite);
Bundled thinCore.dll is 32-bit. Target PlatformTarget=x86 (or Prefer 32-bit). x64/Arm64 cannot load the native DLLs.
thinCore uses ANSI BSTRs. Prefer ASCII / system-ANSI-safe text. Return strings with AllocReturnString — do not free them yourself.
Delegates passed to LoadSymbol stay rooted until ClearSymbolCallbacks(). Call it only when no script can still invoke those keywords.
Script errors may show a thinBasic dialog and leave engine state sticky. Prefer validating scripts; avoid relying on failed Run in long-lived hosts.
NuGet install · build · examples
Install-Package ThinBasic.NET
# or
dotnet add package ThinBasic.NET
dotnet build ThinBasic.NET\ThinBasic.NET.csproj -c Release -p:Platform=x86
dotnet test ThinBasic.NETTests\ThinBasic.NETTests.csproj -c Release -p:Platform=x86
dotnet run --project ThinBasic.Example -c Release -p:Platform=x86 -- embed
# host | parser | array | isolated | hash | class
Requirements
Windows 10+ · x86 only · .NET 8 / 9 / 10 (windows) · ships thinCore.dll + thinBasic_UI.dll (ThinBasic 1.14 era)
Install the package, target Windows x86, and embed ThinBasic in your host application in minutes.