[IronPython] Modifying Parameters
Patrick Burrows
pburrows at gmail.com
Tue Apr 8 01:19:42 CEST 2008
nevermind. figured it out. (of course)
need ".Value" on my python. So the simple python becomes:
number1.Value = 2
number2.Value = 3
(duh!... looking for the problem in all the wrong places)
On Mon, Apr 7, 2008 at 6:58 PM, Patrick Burrows <pburrows at gmail.com> wrote:
> Perhaps a simple question, but I am having problems finding the answer. I
> am hosting IronPython (1.1.1) in a C# application. My IronPython method
> modifies the parameters passed to the method (out int). I would very much
> like to get those modified values back. Here is my sample:
>
> //C# method that calls the PythonEngine:
> PythonEngine pe = new PythonEngine();
> EngineModule em = pe.CreateModule("PreCalc",true);
> string[] paramnames = {"number1", "number2"};
> PreCalcMacro pcMac =
> pe.CreateMethod<PreCalcMacro>(GetPreCalcSourceUnitString(), paramnames, em);
> pcMac(out firstNumber, out secondNumber);
> Number1TextBox.Text = firstNumber.ToString();
> Number2TextBox.Text = secondNumber.ToString();
>
>
> //My delegate definition:
> delegate void PreCalcMacro(out int n1, out int n2);
>
> //My IronPython code (the return value of GetPreCalcSourceUnitString() ):
> number1 = 2
> number2 = 3
>
> Now, after this code executes, the values of firstNumber and secondNumber
> remain unchanged.
> What do I need to do to have these values update to what the python method
> set them to?
>
> Thanks!
>
>
--
--
Patrick Burrows
http://www.CleverHumans.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080407/24c0f845/attachment.html>
More information about the Ironpython-users
mailing list