Ring/Lessons/Embedding Ring Interpreter in C/C++ Programs

Embedding Ring Interpreter in C/C++ Programs
We can call the Ring interpreter from C/C++ programs using the next functions

Ring State
The idea is to use the ring_state_init to create new state for the Ring Interpreter then call the ring_state_runcode function to execut Ring code using the same state. When we are done, we call the ring_state_delete to free the memory.

Example:

Output:

Ring State Functions
The Ring API comes with the next functions to create and delete the state. Also we have functions to create new variables and get variables values.

Ring State Variables
We can create more than one ring state in the same program and we can create and modify variable values.

To get the variable list we can use the ring_state_findvar function.

To create new variable we can use the ring_state_newvar function.

Example:

Output: