Greg Akins
2008-Jan-28 01:30 UTC
[Ironruby-core] Still plugging away at some simple IronRuby stuff
OK, I''m making progress.. Though my wife just got home, so this might
not last much longer ;-)
I am following the example at
http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp
NOTE: I tried to be helpful and update that page with the examples
that were just posted to the list, but now the page includes this the
IScriptModule().SetVariable code - which doesn''t appear to be valid
anymore)
This is what I''m using instead and I get a MissingMethod error on
widget. I''d try using this method (
scriptenvironment.ExecuteSourceUnit(rubyengine.CreateScriptSourceFromString(script)
); ) but CreateScriptSourceFromString doesn''t appear to have a
signature for IScriptModule, or IScriptScope.
Thoughts?
IScriptEnvironment scriptenvironment
ScriptEnvironment.GetEnvironment();
IScriptEngine rubyengine =
scriptenvironment.GetEngine("ruby");
string script = "puts ''Ruby and '' +
widget.to_s + ''
together at last''";
IScriptScope scope = scriptenvironment.CreateScope();
scope.SetVariable("widget", ".Net");
rubyengine.Execute(scope,
rubyengine.CreateScriptSourceFromString(script));
Console.ReadKey();
--
Greg Akins
Software Development Manager
SSI Services
http://kc.vanadium.com
http://www.pghcodingdojo.org
http://www.insomnia-consulting.org/monologue
Michael Letterle
2008-Jan-28 13:26 UTC
[Ironruby-core] Still plugging away at some simple IronRuby stuff
IScriptModule is now IScriptScope from what I understand. I couldn''t
figure out how to create or access local or instance variables, but
you can use a global.
I got this:
using System;
using Ruby;
using Ruby.Runtime;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
namespace RubyExample
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
IScriptEngine rubyengine
IronRuby.GetEngine(IronRuby.CreateRuntime());
IronRuby.GetExecutionContext(rubyengine.Runtime).GlobalVariables[SymbolTable.StringToId("widget")]
= ".NET";
rubyengine.Execute(rubyengine.CreateScope(),
rubyengine.CreateScriptSourceFromString("puts ''Ruby and
'' +
$widget.to_s + '' together at last''"));
Console.ReadKey();
}
}
}
On Jan 27, 2008 8:30 PM, Greg Akins <angrygreg at gmail.com>
wrote:> OK, I''m making progress.. Though my wife just got home, so this
might
> not last much longer ;-)
>
> I am following the example at
> http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp
>
> NOTE: I tried to be helpful and update that page with the examples
> that were just posted to the list, but now the page includes this the
> IScriptModule().SetVariable code - which doesn''t appear to be
valid
> anymore)
>
> This is what I''m using instead and I get a MissingMethod error on
> widget. I''d try using this method (
>
scriptenvironment.ExecuteSourceUnit(rubyengine.CreateScriptSourceFromString(script)
> ); ) but CreateScriptSourceFromString doesn''t appear to have a
> signature for IScriptModule, or IScriptScope.
>
> Thoughts?
>
> IScriptEnvironment scriptenvironment >
ScriptEnvironment.GetEnvironment();
> IScriptEngine rubyengine =
scriptenvironment.GetEngine("ruby");
>
> string script = "puts ''Ruby and '' +
widget.to_s + ''
> together at last''";
> IScriptScope scope = scriptenvironment.CreateScope();
> scope.SetVariable("widget", ".Net");
> rubyengine.Execute(scope,
> rubyengine.CreateScriptSourceFromString(script));
> Console.ReadKey();
>
>
>
> --
> Greg Akins
> Software Development Manager
> SSI Services
>
> http://kc.vanadium.com
> http://www.pghcodingdojo.org
> http://www.insomnia-consulting.org/monologue
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
--
Michael Letterle
[Polymath Programmer]
http://michaeldotnet.blogspot.com
Greg Akins
2008-Feb-03 22:11 UTC
[Ironruby-core] Still plugging away at some simple IronRuby stuff
On Jan 27, 2008 8:30 PM, Greg Akins <angrygreg at gmail.com> wrote:> > > I am following the example at > http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp > > NOTE: I tried to be helpful and update that page with the examples > that were just posted to the list, but now the page includes this the > IScriptModule().SetVariable code - which doesn''t appear to be valid > anymore)FYI, I just updated this page to fix the problem I caused last weekend. -- Greg Akins Software Development Manager SSI Services http://kc.vanadium.com http://www.pghcodingdojo.org http://www.insomnia-consulting.org/monologue