[Mono-dev] Need PutVar method on Mono.CSharp.Evaluator

Tom Spink tspink at gmail.com
Mon Aug 15 11:44:05 EDT 2011


On 15 August 2011 16:36, Charles Rich <rich at wpi.edu> wrote:

> Hi Mark, Thanks for the reply, but that just pushes the problem one
> level back, i.e., how is 'whatever' set to the result of the
> evaluation?   The point is that I need to be able to pass the result
> of the evaluation around *outside* the evaluator and then feed it back
> in.
>
> -CR
>
> On Mon, Aug 15, 2011 at 11:27 AM, Marek Safar <marek.safar at gmail.com>
> wrote:
> > Hello,
> >>
> >> Hi, I am new to Mono, but becoming a big fan quickly (more detail
> >> below regarding what I am doing with it).  To get right to the point,
> >> however, I would appreciate advice on how to *programmatically* set
> >> the value of a variable that can be seen inside the Evaluator, e.g.,
> >>
> >>        var temp = Evaluator.Evaluate("...");
> >>        Evaluator.PutVar("x", temp); // so such method exists!
> >>        Evaluator.Run("... x ...");
> >
> > You can simply run C# statement which will do the assignment. Trivial
> > example can look like this
> >
> > Evaluator.Run("x = whatever");
> >
> > Marek
> >
>
>
>
> --
> Dr. Charles Rich, Professor of Computer Science
> Interactive Media and Game Development
> Worcester Polytechnic Institute, Fuller Laboratories B25b
> 100 Institute Road, Worcester, MA 01609-2280
>
> Email: rich at wpi.edu   Phone: 508-831-5945   Fax: 508-831-5776
> Home: http://www.cs.wpi.edu/~rich
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>

Hi Charles,

I think what Marek is trying to say is, instead of consuming the output of
the first evaluate method, perform an assignment to a variable, then reuse
that variable in subsequent calls:

>>        var temp = Evaluator.Evaluate("...");
>>        Evaluator.PutVar("x", temp); // so such method exists!
>>        Evaluator.Run("... x ...");

Evaluator.Run("var x = ...");
Evaluator.Run("... x ...");

If you need to get 'x' out, then you can use the GetVars() method as you
have previously found.

-- 
Tom Spink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110815/d56a32df/attachment.html 


More information about the Mono-devel-list mailing list