[IronPython] Modifying Parameters

Patrick Burrows pburrows at gmail.com
Tue Apr 8 00:58:55 CEST 2008


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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080407/104cd64c/attachment.html>


More information about the Ironpython-users mailing list