I am using IronPython within a C# .NET application.
I have a class that the Python code uses, so I create a scope and set the
variable, then execute the engine like this:
private ScriptEngine scptEngine = null;
private ScriptRuntime scptRuntime = null;
private ScriptScope scptScope;
private ScriptSource scptSource;
public pyEngine()
{
scptEngine = Python.CreateEngine();
scptRuntime = scptEngine.Runtime;
scptScope = scptEngine.CreateScope();
AddAssemblies(scptRuntime);
SOA SOA_screen = new SOA(); // my Class
scptScope.SetVariable("screen", SOA_screen);
scptSource =
scptEngine.CreateScriptSourceFromFile(scriptFile);
scptSource.Execute(scptScope);
}
This runs fine. But within the Python code, if I detect an error, I want to
exit out of scriptFile.
I check a flag and try to exit if flag is false: so, the basic python is:
if MessageScreenIsActive == False :
screen.Say("CAN NOT PROCEED: " + screen.lastResultMessage);
sys.exit()
This throws an exception. But this:
if MessageScreenIsActive == False :
screen.Say("CAN NOT PROCEED: " + screen.lastResultMessage);
sys.exit
only exits the <IF block> -- not the whole script.
Of course, I can bracket off all of my code with if/else and control it this
way, but there must be a simple way to simple exit the script... isn't
there?
Thanks for reading!
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com