# Hosting the DLR and passing data to scripts

**URL:** <https://www.ruby-forum.com/t/hosting-the-dlr-and-passing-data-to-scripts/119567>\
**Category:** IronRuby\
**Created:** [November 8, 2007, 12:44am UTC](https://www.ruby-forum.com/t/hosting-the-dlr-and-passing-data-to-scripts/119567 "2007-11-08T00:44:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josetomas\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@josetomas\_r](https://www.ruby-forum.com/u/josetomas_r)\
**Post date:** [November 8, 2007, 12:44am UTC](https://www.ruby-forum.com/t/hosting-the-dlr-and-passing-data-to-scripts/119567/1 "2007-11-08T00:44:44Z")

</div>

I’ve been playing with the DLR hosting interfaces and running ruby code  
this  
way; it’s a really, really nifty feature that I’m already loving!

I can see a lot of cool scenarios this will be useful, such as providing  
a  
good way to provide custom scripting support on applications and so on.

I have had some problems, however, in particularly trying to connect the  
host with the scripts being executed inside the DLR. In my infinite  
ignorance, I assume you would be able to use Script.SetVariable() (or  
one of  
the longer, but equal alternatives to it) to introduce global variables  
into  
the scope before executing or evaluating a script, but for the life of  
me I  
can’t seem to get it to work.

Am I just completely of the mark? or is it just not working at this  
time?

---

<div class="post-metadata">

**Author:** ![josetomas\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@josetomas\_r](https://www.ruby-forum.com/u/josetomas_r)\
**Post date:** [November 8, 2007, 4:54am UTC](https://www.ruby-forum.com/t/hosting-the-dlr-and-passing-data-to-scripts/119567/2 "2007-11-08T04:54:50Z")

</div>

Weâ€™re going to improve hosting API in DLR next month â€“ there will be  
several major changes and many minor ones. IronRuby will also plug  
better to DLR due to these changes. For the time being, use only globals  
(via RubyEngine.CurrentEngine.ExecutionContext.GlobalVariables  
dictionary) for passing data from and to Ruby scripts.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tomas R.  
Sent: Wednesday, November 07, 2007 3:44 PM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Hosting the DLR and passing data to scripts

I’ve been playing with the DLR hosting interfaces and running ruby code  
this way; it’s a really, really nifty feature that I’m already loving!

I can see a lot of cool scenarios this will be useful, such as providing  
a good way to provide custom scripting support on applications and so  
on.

I have had some problems, however, in particularly trying to connect the  
host with the scripts being executed inside the DLR. In my infinite  
ignorance, I assume you would be able to use Script.SetVariable() (or  
one of the longer, but equal alternatives to it) to introduce global  
variables into the scope before executing or evaluating a script, but  
for the life of me I can’t seem to get it to work.

Am I just completely of the mark? or is it just not working at this  
time?

–  
Tomas R.  
[http://www.winterdom.com/weblog/](http://www.winterdom.com/weblog/)

---

<div class="post-metadata">

**Author:** ![josetomas\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@josetomas\_r](https://www.ruby-forum.com/u/josetomas_r)\
**Post date:** [November 8, 2007, 1:43pm UTC](https://www.ruby-forum.com/t/hosting-the-dlr-and-passing-data-to-scripts/119567/3 "2007-11-08T13:43:49Z")

</div>

Hi Tomas,

\<\<  
Weâ€™re going to improve hosting API in DLR next month â€“ there will be  
several major changes and many minor ones. IronRuby will also plug  
better to DLR due to these changes. For the time being, use only globals  
(via RubyEngine.CurrentEngine.ExecutionContext.GlobalVariables  
dictionary) for passing data from and to Ruby scripts.

> >

Thanks for the answer; I’ll keep my eyes on the DLR updates.

I did try using the GlobalVariables dictionary and that did work fine.  
Any particular reason why the global variables are stored in the  
GlobalVariables dictionary instead of the GlobalScope dictionary? (just  
trying to understand better how it works)

Tomas R.  
[http://www.winterdom.com/weblog/](http://www.winterdom.com/weblog/)
