3.4 Program execution



An AVIL program can be executed from a sketch in a very simple way:

1 #include <avil.h>
2 
3 avil interpreter;
4 
5 void setup(void) {
6   
7   if(!interpreter.init()){
8      //something wrong during initialization...want to do something? 
9   }
10 
11   //run the program blink on sd
12   interpreter.run("blink");
13 }
14 
15 
16 void loop(void) {
17   //nothing to do here...
18 }

You can also pass some arguments to an AVIL's program, as expected, you can doi it like this:

1 #include <avil.h>
2 
3 avil interpreter;
4 
5 void setup(void) {
6   
7   if(!interpreter.init()){
8      //something wrong during initialization...want to do something? 
9   }
10 
11   //run a program with a string argument
12   interpreter.run("touch \"foo\"");
13 }
14 
15 
16 void loop(void) {
17   //nothing to do here...
18 }

While a program is running you can "kill" it using the "kill key" (by default is "ESC").
If you're working with serial you can stop an AVIL program just pressing the "ESC" key.
If you're working with ethernet you can stop an AVIl program running pressing the "ESC" key+"Enter".

Ther'se no (at the moment) a way to check the syntax of an AVIL program, but if some errors occurs while running the interpreter stop the execution of the program and produce output to help you debug your program.
You can find a list of errors here.