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

Charles Rich rich at WPI.EDU
Wed Aug 10 22:04:54 EDT 2011

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 ...");

I would like the value of x in the third line above to be the object
that was returned from the call to Evaluate in the first line.  Now,
obviously, if the value of temp is a number or a string, I can just
concatenate it into the string argument to Run, e.g.,
"..."+temp+"...".   But that doesn't work if temp is some other data

It is tantalizing that Evaluator has a GetVars() method (even though
it returns a string)---so it is indeed keeping track of the defined
variables!   Btw, I wouldn't mind if I needed to initialize x with a
var statement at the start.

So I guess, for the long term, I am asking for a new PutVar method;  I
am also hoping for some kind of workaround in the short term, so I can
finish my project (see below).  Is there some way to directly access
the global Mono environment (from C#) to simply set a variable?

Thanks in advance,


P.S. My larger project is converting an AI system for controlling
NPC's, written in Java, for use in Unity3d.   I have used ikvmc (see
ikvm.net) successfully to do the Java translation, but there is a
remaining problem with changing the embedded scripting language to C#
(to easily access Unity3d game state---like the REPL at
https://github.com/MrJoy/UnityREPL), which leads this email.
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

More information about the Mono-devel-list mailing list