Qore Programming Language
0.8.11.1
|
The first step is to initialize the library. To do this, call qore_init() as follows (note that this function can only be called once and must be called before any other functionality of the Qore library is used):
When your program terminates, you should call qore_cleanup() as follows:
First you should declare a variable of type ExceptionSink to capture and manage Qore exceptions (declare an additional variable if you want to capture and manage warnings when parsing Qore code):
Then you can use the QoreProgramHelper class to manage QoreProgram objects. The QoreProgramHelper class contains a QoreProgram object and calls QoreProgram::waitForTerminationAndDeref() in the destructor. The constructor takes a pointer to an ExceptionSink object, so make sure that the ExceptionSink object has at least as long a scope as the QoreProgramHelper object, as follows:
Then the QoreProgramHelper object can be used like a QoreProgram object. For example, to parse a file named "test.q" and run it, do the following:
There are many functions for parsing and running Qore code; see the QoreProgram class documentation for more information.