Setting and getting variables in .Net hosted IronPython script -
I am trying to prototype a validation rule engine by using a hosted IronPython in the .Net console application. I have correctly stripped the script which I believe is the basics
var engine = python Cretegenine (); Engine.Execute ("From System Import" ""); Engine. time. Global .Set Variable ("Property_View", "TB Test"); Engine. time to time. Globe Set variables ("result", true); Var sourceScope = engine.CreateScriptSourceFromString ("result = properties_value = none and lane (property_value)> = 3"); SourceScope.Execute (); Bull results = engine. time to time. Globe Meets ("result"); Engine.Runtime.Shutdown ();
It can not detect the global variable which I think is set up.
The global name 'property_value' is not defined
But I can check the global variable in the realm and this is there - this statement is correct when I Runs in the debugger
sourceScope.Engine.Runtime.Globals.ContainsVariable ("property_value")
I If this is an easy / clear question then IronPathon With a full newbie so apologizes.
This is making general inspiration, but with the (most recent) version of Ironpathon where some methods and signatures have changed.
Here I provide the script with one variable and then pick the result:
var engines = python Cretegenine (); Var scope = engine.CreateScope (); Scope .set variable ("Foo", 42); Engine.Execute ("print foo; bar = foo + 11", scope); Console.WriteLine (scope.GetVariable ("bar"));
Comments
Post a Comment