Initialization - KidneyThief/TinScript1.0 GitHub Wiki
The integration of TinScript into a C++ solution is through the class CScriptContext. It is the entry point for all interaction, and requires the following steps:
- Header files - all files requiring access to the tinscript.lib interface need to include:
- #include "TinScript.h"
#include "TinRegistration.h"
- #include "TinScript.h"
- Create the context:
-
TinScript::CreateContext(<print handler>, <assert handler>, bool is_main_thread);
- The print handler is simply a function to handle formatted printf() calls generated by TinScript, allowing you to direct the output as needed.
- The assert handler is a bit more complicated, but serves the same purpose - how to handle asserts, such as syntax errors while parsing scripts. There is a default assert handler provided in cmdshell.h.
-
TinScript::CreateContext(<print handler>, <assert handler>, bool is_main_thread);
- Update the context:
-
TinScript::UpdateContext(<current time msec>);
- You'll need to update the context with the current (not delta) time in milliseconds. This allows the scheduler to process the commands it has queued up.
- It's perfectly valid to call ::UpdateContext() with the same current time as the last update - this is the equivalent of the system being "paused".
-
TinScript::UpdateContext(<current time msec>);
- Destroy the context:
-
TinScript::DestroyContext();
- Once the application is finished, and you are shutting down the system, destroying the context will clean up all traces of Tinscript.
-
TinScript::DestroyContext();