Interactive Small Basic (ISB) is a simple scripting language derived from Microsoft Small Basic.
ISB is a light-weight solution to support the following scenarios:
- As an in-game scripting language, to be embedded in Unity games.
- As a shell scripting language, to provide a command-line interface where simple code can be executed to control the host system.
ISB is implemented in C# as the original Microsoft Small Basic does.
In your .Net project, add the NuGet package of ISB:
dotnet add package ISB
Now you are ready to create an instance of the ISB engine to compile and run BASIC code. For example, here is a C# program that runs ISB:
using System.Collections.Generic;
using ISB.Runtime;
using ISB.Utilities;
namespace test
{
class Program
{
static void Main(string[] args)
{
var engine = new Engine("test");
string code = "print(\"Hello, World!\")";
engine.Compile(code, true);
if (engine.HasError)
{
ReportErrors(engine.ErrorInfo.Contents);
return;
}
engine.Run(true);
if (engine.HasError)
{
ReportErrors(engine.ErrorInfo.Contents);
return;
}
}
private static void ReportErrors(IReadOnlyList<Diagnostic> diagnostics)
{
foreach (var diagnostic in diagnostics)
{
System.Console.WriteLine(diagnostic.ToDisplayString());
}
}
}
}
ISB can be embedded in Unity projects as an in-game scripting language.
ISB supports running as a Unity coroutine so that the execution of ISB code won't block the main loop, no multi-threading needed.
See Unity Integration Demos for example code.
See ISB's git repo https://github.com/wixette/isb for more details.