Envision Gallery
This gallery contains sample Envision scripts and sample datasets.
VS Code extension for Envision
While Envision is usually intended to be authored via the web-based integrated development environment provided by Lokad, there is also a VS Code extension for Envision. This extension provides code coloring and compilation support (via the public compilation endpoint).
Pretty-print Envision scripts
To pretty-print Envision scripts in a web page, you should:
- include the JavaScript file
https://docs.lokad.com/js/envision.min.js
- use
<code class=language-envision data-lang=envision>
blocks to introduce you scripts. - call
globalThis.highlightElementsWithClass('language-envision')
The following minimal HTML page illustrates the process:
<!DOCTYPE html>
<html lang="en">
<head>
<script src=https://docs.lokad.com/js/envision.min.js></script>
</head>
<body>
<code class=language-envision data-lang=envision>
montecarlo 1000 with // approximate π value
x = random.uniform(-1, 1)
y = random.uniform(-1, 1)
inCircle = x^2 + y^2 < 1
sample approxPi = avg(if inCircle then 4 else 0)
show scalar "π approximation" with approxPi // 3.22
</code>
<script>
syntax.highlightElementsWithClass('language-envision');
</script>
</body>
</html>
Lokad grants you the right to host a local copy Envision.min.js
.
Public compilation endpoint for Envision
This endpoint takes an Envision script as input, and returns the compilation errors, if any.
- URL:
https://try.lokad.com/w/script/trycompile
- Method:
POST
The payload to be sent in the HTTP request body is a JSON object with the following structure:
{
"Script": "show label \"Welcome to Envision!\" a1b1 tomato"
}
The response properties include IsCompOk
(Boolean) and CompMessages
(array). If the compilation fails, then the IsCompOk
property will be false
, and the CompMessages
array will contain one or more objects, each representing an error or a warning message, as illustrated by:
{
"IsCompOk": false,
"CompMessages": [
{
"Text": "Compilation error message",
"Line": 10,
"Start": 5,
"Length": 15,
"Severity": "Error"
}
]
}