I tried to following code in my simple test app:<br><br>var1 = "Josh"<br>for i in range(5):<br> print i<br><br>pe.ExecuteCommand threw a SyntaxErrorException, "unexpected token 'for' exception.<br>
<br>It works fine if execute it in a file like, ipy test.py at the command line.<br><br>If I leave off the "var1 = "Josh", and the for loop starts at the first line, it works.<br>The problem I am having probably stems from my lack of understanding of the ipy engine, but I though that this statement:
<br><br><div style="margin-left: 40px;">If you're executing code from a multiline textblock - then it shouldn't<br>be a problem as you won't be executing code one line at a time...<br><br></div>suggested my code would work.
<br><br>- Josh Pearce<br><br><div><span class="gmail_quote">On 10/20/07, <b class="gmail_sendername">Michael Foord</b> <<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Joshua J. Pearce wrote:<br>> Thanks! Where can I find help with getting the python engine to deal<br>> with the indents involved with loops, defs, and such?<br>Well - indents and loops and such is just ordinary Python code. Do you
<br>want this code to be entered one line at a time, like an interactive<br>interpreter?<br><br>If you're executing code from a multiline textblock - then it shouldn't<br>be a problem as you won't be executing code one line at a time...
<br><br>In Mike Stall's article<br><br>'Evaluate' executes a single expression and returns the result.<br><br>'Execute' executes a block of code.<br><br>That article is from 2005 though.<br><br>Michael
<br><a href="http://www.manning.com/foord">http://www.manning.com/foord</a><br><br>> I read Mike Stalls article, 10 Easy Steps to Embedding..., but I still<br>> can't understand the difference between evaluate and execute methods.
<br>><br>> I am trying to use IPY as a scripting language for my <a href="http://ASP.NET">ASP.NET</a><br>> <<a href="http://ASP.NET">http://ASP.NET</a>> app, so I really need to know how to build my own<br>
> shell in C# in addition to the help you all have already given me in<br>> using my c# classes in the python code.<br>><br>> Thanks!<br>><br>> On 10/19/07, *Michael Foord* <<a href="mailto:fuzzyman@voidspace.org.uk">
fuzzyman@voidspace.org.uk</a><br>> <mailto:<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>>> wrote:<br>><br>> Joshua J. Pearce wrote:<br>> > What am I doing wrong? I have a form with two text boxes and a
<br>> button.<br>> > When I type, "tb.clear()" into the first textbox and click the<br>> button,<br>> > I get the a MissingMemberException which states, "'TextBox'<br>
> object has<br>> > no attribute 'clear'".<br>><br>> Do you mean "tb.Clear()" ?<br>><br>> Michael<br>><br>><br>> ><br>> ><br>> > public partial class Form1 : Form
<br>> > {<br>> > public static PythonEngine pe = PythonEngine.CurrentEngine;<br>> > public Form1()<br>> > {<br>> > InitializeComponent();
<br>> ><br>> ><br>> ScriptDomainManager.CurrentManager.Host.DefaultModule.SetVariable("tb",<br>> > textBox2);<br>> > }<br>> ><br>> ><br>
> > private void button1_Click(object sender, EventArgs e)<br>> > {<br>> > pe.ExecuteCommand (textBox1.Text);<br>> ><br>> > }<br>> > }
<br>> ><br>> ><br>> > Thanks,<br>> ><br>> > Josh Pearce<br>> ><br>> ><br>> > On 10/18/07, *Joshua J. Pearce* < <a href="mailto:joshua.pearce@gmail.com">
joshua.pearce@gmail.com</a><br>> <mailto:<a href="mailto:joshua.pearce@gmail.com">joshua.pearce@gmail.com</a>><br>> > <mailto: <a href="mailto:joshua.pearce@gmail.com">joshua.pearce@gmail.com</a>
<br>> <mailto:<a href="mailto:joshua.pearce@gmail.com">joshua.pearce@gmail.com</a>>>> wrote:<br>> ><br>> > I am very sorry! I just noticed this:<br>> ><br>> >
ScriptDomainManager.CurrentMan<br>> > ager.Host.DefaultModule.SetVariable("SomeName",<br>> > SomeObject);<br>> ><br>> > SomeObject is then available to user code as SomeName...
<br>> ><br>> > That is exactly what I want to do!!!<br>> ><br>> > Thank you very much!<br>> ><br>> ><br>> ><br>> > On 10/18/07, *JoeSox* <
<a href="mailto:joesox@gmail.com">joesox@gmail.com</a><br>> <mailto:<a href="mailto:joesox@gmail.com">joesox@gmail.com</a>> <mailto:<a href="mailto:joesox@gmail.com">joesox@gmail.com</a><br>> <mailto:
<a href="mailto:joesox@gmail.com">joesox@gmail.com</a>>>><br>> > wrote:<br>> ><br>> > On 10/18/07, Joshua J. Pearce < <a href="mailto:joshua.pearce@gmail.com">joshua.pearce@gmail.com
</a><br>> <mailto:<a href="mailto:joshua.pearce@gmail.com">joshua.pearce@gmail.com</a>><br>> > <mailto:<a href="mailto:joshua.pearce@gmail.com">joshua.pearce@gmail.com</a><br>> <mailto:
<a href="mailto:joshua.pearce@gmail.com">joshua.pearce@gmail.com</a>>>> wrote:<br>> > > My application is <a href="http://ASP.NET">ASP.NET</a> <<a href="http://ASP.NET">http://ASP.NET</a>>
<br>> <<a href="http://ASP.NET">http://ASP.NET</a>>, I hardly think<br>> > integrating CPython is going to be a better choice.<br>> ><br>> > You never mentioned you were using
<a href="http://ASP.NET">ASP.NET</a><br>> <<a href="http://ASP.NET">http://ASP.NET</a>> <<a href="http://ASP.NET">http://ASP.NET</a>>.<br>> > You have mentioned C#.<br>> ><br>
> > > Is is possible to 'expose' c# methods that exist in<br>> the same<br>> > scope as an IPY<br>> > > engine,<br>> ><br>> > Can you clarify what you mean by this line for me? Can you
<br>> > provide a<br>> > C# method that exists in the same scope as an IPY engine?<br>> ><br>> > There must be a custom interface, how would an outside<br>> script know
<br>> > about a custom method outside it's scope without an custom<br>> > interface?<br>> > Michael and myself have both provided examples.<br>> ><br>> > If you have a C# method it must be represented by something
<br>> > else in<br>> > the script or python code that IronPythonEngine is<br>> using, then<br>> > update<br>> > the script or python code loaded in the IronPythonEngine
<br>> using<br>> > the<br>> > examples provided.<br>> ><br>> > Since I have not seen your source, I don't know why you<br>> believe<br>> > importing the AppService dll and create your own
<br>> instance in<br>> > the IP<br>> > engine will be too much overhead. That sounds like the bet<br>> > way to go<br>> > but I am not familiar with your source.
<br>> > Good Luck!<br>> > --<br>> > Later, JoeSox<br>> > _______________________________________________<br>> > Users mailing list<br>
> > <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>> <mailto:<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a>> <mailto:<br>>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a> <mailto:<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a>>><br>> ><br>> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>> <<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a>>
<br>> ><br>> ><br>> ><br>> ><br>> > --<br>> > Joshua Pearce<br>> ><br>> ><br>> ><br>> ><br>> > --<br>> > Joshua Pearce
<br>> ><br>> ------------------------------------------------------------------------<br>><br>> ><br>> > _______________________________________________<br>> > Users mailing list
<br>> > <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a> <mailto:<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a>><br>> > <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>> ><br>><br>> _______________________________________________<br>> Users mailing list<br>> <a href="mailto:Users@lists.ironpython.com">
Users@lists.ironpython.com</a> <mailto:<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a>><br>> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
</a><br>><br>><br>><br>><br>> --<br>> Joshua Pearce<br>> ------------------------------------------------------------------------<br>><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">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
</a><br>><br><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">
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br></blockquote></div><br><br clear="all"><br>-- <br>Joshua Pearce<br>