www.digitalmars.com         C & C++   DMDScript  

DMDScript - DMDScript and D interaction

reply "Carlos Santander B." <csantander619 gmail.com> writes:
How many of you were/are trying to do the same that I am? That is, try 
to integrate DMDScript with D.

What I have done is modified slightly Walter's testscript so it becomes 
a sort of interactive shell (it really isn't, but it takes its input 
from console instead from a file). Anyway, I could create a DMDScript 
variable from a D one. What I did was prepend to the user input code of 
my own, just like this:

buffer = "var myValue = " ~ format(myValue) ~ ";" ~ userInput;

So the user can use "myValue", and she can even modify it. The problem 
is that past that point, I want to recover in D the value of "myValue" 
and see if it changed. Can it be done? How? (extra points if there's a 
way to notify from DMDScript to D the moment "myValue" changes ;) ).

_______________________
Carlos Santander Bernal
Jan 20 2005
parent reply "Walter" <newshound digitalmars.com> writes:
"Carlos Santander B." <csantander619 gmail.com> wrote in message
news:csp8s9$tcc$1 digitaldaemon.com...
 How many of you were/are trying to do the same that I am? That is, try
 to integrate DMDScript with D.

 What I have done is modified slightly Walter's testscript so it becomes
 a sort of interactive shell (it really isn't, but it takes its input
 from console instead from a file). Anyway, I could create a DMDScript
 variable from a D one. What I did was prepend to the user input code of
 my own, just like this:

 buffer = "var myValue = " ~ format(myValue) ~ ";" ~ userInput;

 So the user can use "myValue", and she can even modify it. The problem
 is that past that point, I want to recover in D the value of "myValue"
 and see if it changed. Can it be done? How? (extra points if there's a
 way to notify from DMDScript to D the moment "myValue" changes ;) ).

The way to do that is create your own object (by deriving from DObject). Then, override the Put() functions to notify when a property gets a new value.
Jan 20 2005
parent reply "Carlos Santander B." <csantander619 gmail.com> writes:
Walter wrote:
 The way to do that is create your own object (by deriving from DObject).
 Then, override the Put() functions to notify when a property gets a new
 value.
 
 

Thanks. I managed to get it working: http://dblinux.sis.epn.edu.ec/~csantand/dmdscript.html Maybe I'll upload the executables tomorrow (if someone requests them). _______________________ Carlos Santander Bernal
Jan 21 2005
parent "Walter" <newshound digitalmars.com> writes:
"Carlos Santander B." <csantander619 gmail.com> wrote in message
news:cssgst$1mn4$1 digitaldaemon.com...
 Walter wrote:
 The way to do that is create your own object (by deriving from DObject).
 Then, override the Put() functions to notify when a property gets a new
 value.

Thanks. I managed to get it working: http://dblinux.sis.epn.edu.ec/~csantand/dmdscript.html Maybe I'll upload the executables tomorrow (if someone requests them).

Great!
Jan 22 2005