dynamic language runtime - How to redirect the input of ironruby to a textbox (WinForms & Silverlight 4) -


I am creating an IronRuby console in Silverlight 4 and WinForms (net4). I can redirect output without problems:

  MyRuntime = Ruby.CreateRuntime (); MsOutput = New MemoryStream (); MyRuntime.IO.SetOutput (msOutput, Encoding.UTF8); MyEngine = MyRuntime.GetEngine ("RB"); MySource = MyEngine.CreateScriptSourceFromString ("A = '123' \ n Disputes one, SourceCodeKind.Statements); MySource.Execute (); Textbox2.Text = ReadFromStream (msOutput);  

Now, I also want to redirect the input, but always getting 'blue' from the script:

  MyRuntime = Ruby.CreateRuntime (); MsOutput = New MemoryStream (); MsInput = New MemoryStream MyRuntime.IO.SetOutput (msOutput, encoding. UTF8); MyRuntime.IO.SetInput (msInput, encoding. UTF8); MyEngine = MyRuntime.GetEngine ("RB"); MySource = MyEngine.CreateScriptSourceFromString ("A = \" N becomes one ", SourceCodeKind.Statements); Byte [] byte = encoding. UTF8.GetBytes (" 123 "); MsInput.Writ E (bytes, 0, byte length); MySource.Execute (); Textbox2.Text = ReadFromStream (msOutput);  

I have not received any samples of input redirect, do you Can I send an example? Thank you.

I do not have any sample code immediately available, When applying the stream instead of using MemoryStream, you need to send the "content" of the text box to the stream when it reads on the stream. You will need some mechanism to set up content to send - eg When the user returns, you will probably need to set up a thread to block to read and possibly use the AutoSetset to block until the text box signal is completed.


Comments