Original Post
Hello, Today i have successfully tested my first AS script. What I have need of now is how i can reliably execute the script one statement at a time so that if I want I can pause the execution of the script by pressing a button, or stop the execution altogether. something along the lines of
int sum = 0;
char *Script =
"for(int i = 0; i < 10; i++)\n"
"{\n"
"\tsum += i;\n"
"}";
engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->AddScriptSection("module", "section", Script, ScriptLength, 0);
engine->Build("module", 0);
engine->RegisterGlobalProperty("int sum", ∑);
int r = engine->ExecuteString("module", Script);
while(r != 0)
{
while(b_PauseScript)
Sleep(100);
if(b_StopScript)
break;
r = execute_next_statement();
}