Robots/Wren: Difference between revisions

m
Minor tidy
(→‎Code: Sharper colors.)
m (Minor tidy)
 
(One intermediate revision by the same user not shown)
Line 1:
===Code===
{{trans|Go}}
{{libheader|ncurses}}
Line 7:
{{works with|Ubuntu 20.04}}
An embedded script so we can use the ncurses library.
<langsyntaxhighlight ecmascriptlang="wren">/* robotsRobots.wren */
 
import "./dynamic" for Struct
Line 298:
NC.echo()
NC.endwin()
NC.cursSet(1)</langsyntaxhighlight>
<br>
We now embed this in the following C program, build and run it.
<langsyntaxhighlight lang="c">/* gcc robotsRobots.c -o robotsRobots -lncurses -lwren -lm */
 
#include <stdio.h>
Line 498:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "robotsRobots.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 519:
free(script);
return 0;
}</langsyntaxhighlight>
9,476

edits