Getting Started

Javascript (browser)

To start using SmolScript in your web browser, you only need to include one smolscript js file:

<script src="https://smolscript.org/smolscript-v0.3d.js"></script>

I strongly recommend downloading a copy of this file and hosting it alongside your app.

This gives you a SmolScript object in the global namescape. Initialize and run a simple smol script like this:

var exampleSmolScriptCode = @"

// This is the smol script program, not .net
var a = 10;

function multiplyA(valueToMultiplyBy) {
a = a * valueToMultiplyBy;
}

multiplyA(10);
";

var vm = SmolScript.SmolVM.Compile(exampleSmolScriptCode);

vm.run();

var valueOfA = vm.getGlobalVar("a");

We're creating a string that contains our smol program code, and then creating a VM by compiling the code. Once we've compiled, if there are no errors, we can .run() the VM to execute the entire program once.

On the last line of this sample, once the program has finished running and control is back in our code, we're getting the value of global variable 'a' from the VM. We only really support a few simple types, but because Smol types 'use' Javascript variables as the underlying types, it's more flexible and than .net.

This is just a very quick getting started sample. You can call Smol functions from your Javascript apps, and you can register JS functions to call from SmolScript. More documentation and samples coming soon.

Github Links

.net version: SmolScriptDotNet

Javascript version: SmolScriptJS

Follow @adrianoconnor

© Copyright Arctus Limited 2023
Created by Adrian O'Connor and made available under the MIT license