1

In ChaiScript, there is a .use() function which takes a file path and loads the file and makes every function and variable available in the script. This is great functionality if you want a file from disk, however I'm looking to do the same but from a file which has been loaded, preprocessed as a string and stored in memory. So pretty much an equivalent to the .use function, taking a string representing the whole script instead of just a path.

Is this possible somehow?

Tobias
  • 924
  • 9
  • 23

1 Answers1

2

I believe you simply want to call the eval function, like:

std::string previouslyLoadedString = loadFileAsString();
chai.eval(previouslyLoadedString);

https://github.com/ChaiScript/ChaiScript/blob/develop/cheatsheet.md#general-1

lefticus
  • 3,346
  • 2
  • 24
  • 28