[IronPython] Need a Good Embedded Example

JoeSox joesox at gmail.com
Wed Oct 17 22:19:16 CEST 2007


On 10/17/07, Joshua J. Pearce <joshua.pearce at gmail.com> wrote:
> I am looking for an embedded IronPython 2.0 example beyond the simple hello
> world one I quoted before.
>
> What I want to know is:
>
> 1) How to get variable output from the script back to my c# code.

I have a quick section in this article...
http://www.codeproject.com/useritems/pswrdgeniron.asp

You can view the source here...
http://pswrdgen.googlecode.com/svn/trunk/pswrdgeniron/pswrdgeniron/Form1.cs

Microsoft.Scripting.ScriptDomainManager.CurrentManager.Host.DefaultModule.SetVariable

> 2) How to call scripts with multiple statements.

multiple statements? Do you mean call the methods in an imported script?

> 3) Do all variables need to be set on the script object, or can their
> declaration just be part of the script code?

It depends what you are doing and how your app is designed.

> 4) Is there a good and simple example anywhere that shows how to host the
> IronPython engine in a c# app and let users manipulate your program objects
> via ipy scripts?

My article above.

> 5) How can I expose c# methods to as IPY functions?

Not sure I understand your question here. Can't you have a c# method
then do something like pe.Execute("my py code here")?
-- 
Later, JoeSox



More information about the Ironpython-users mailing list