<div>Your reference to IronMath.dll indicates that you're using IronPython 1.x. You can find a relevant hosting example at <a href="http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET">http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET</a></div>
<div> </div>
<div>The hosting interface for IronPython 2 is radically different; an equivalent example can be found at <a href="http://www.ironpython.info/index.php/Hosting_IronPython_2">http://www.ironpython.info/index.php/Hosting_IronPython_2</a>.</div>
<div><br> </div>
<div class="gmail_quote">On Fri, Jun 27, 2008 at 7:51 AM, Bob Rosembob <<a href="mailto:brosembob@yahoo.com">brosembob@yahoo.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div>Hi there,</div>
<div> </div>
<div>I apologize if this is a duplicate message. I sent this message last night but don't see it posted. Perhaps I did something wrong and message got lost. </div>
<div> </div>
<div>I need to call Python function from C# to get a value. When I call the script it executes and calculates some value, then I need to call some function to get the result. How do I do that? I have the following snippet of code that seems to execute the script, but I don't know and can't find on line, how to call a function and get value back.</div>
<div> </div>
<div>I added references to my project to the following dlls:</div>
<div>- IronPython.dlll</div>
<div>- IronMath.dll</div>
<div> </div>
<div>In the code I'm using the following:</div>
<div><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>using</p></font></font><font size="2">IronPython.Runtime;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>using</p></font></font><font size="2">IronPython.Runtime.Types;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>using</p></font></font><font size="2">IronPython.Runtime.Operations;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>using</p></font></font><font size="2">IronPython.Hosting;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>using</p></font></font><font size="2">IronPython.Modules;</font>
<p><font size="2"></font> </p>
<p>Here is the code:</p>
<p> </p><font size="2">
<p></p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">PythonEngine</font></font><font size="2"> engine = </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">PythonEngine</font></font><font size="2">();</font><font color="#008000" size="2"><font color="#008000" size="2"></font></font><font size="2">
<p></p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">EngineModule</font></font><font size="2"> module = engine.CreateModule(</font><font color="#a31515" size="2"><font color="#a31515" size="2">"Test"</font></font><font size="2">, </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">true</font></font><font size="2">);
<p></p>
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">try</font></font><font size="2">
<p>{</p>
<p> engine.ExecuteFile(</p></font><font color="#a31515" size="2"><font color="#a31515" size="2">@"Test\Test.py"</font></font><font size="2">, module);
<p>}</p>
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">catch</font></font><font size="2"> (</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Exception</font></font><font size="2"> ex)
<p>{</p>
<p></p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2"> Console</font></font><font size="2">.WriteLine(</font><font color="#a31515" size="2"><font color="#a31515" size="2">"Failed to execute <a href="http://test.py/" target="_blank">Test.py</a> file"</font></font><font size="2">);</font><font size="2">
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> return</font></font><font size="2">;
<p>}</p>
<p> </p>
<p>//call the function????</p>
<p> </p>
<p><font size="3">So how do I do the call to the function?</font></p>
<p><font size="3"></font> </p>
<p><font size="3">Thanks for your help.</font></p>
<p><font size="3">Bob</font></p>
<p><font size="3"></font> </p></font></div></div><br></div></div></div><br></div><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br><br></blockquote></div><br>