Mapping local variables into CInt

Hi All,

  I have embedded CINT in my C++ application by

using the CINT API. I now want to map some of my local variables to CInt but i am unable to figure out how to do it though i have gone through all the CINT reference manuals. Any help in this regard will be appreciated. To make my question more clear, i will give a simple
example below:

int main()
{
int var1=10 , var2;
const char *src=“var2 = var1 * 2;”;
G__init_cint(“cint”);
//Map variable var1 and var 2 into
//CInt’s variable(symbol) table here ???
G__exec_text(src);
cout << var2 << endl; //this should print out “20”
// because of 10 * 2
G__scratch_all();
}

Thank you very much for your help

Batu Akan

See the answer to your mail from Masa:

[quote]Hello Akan,

I am happy to answer your question.

Unfortunately, there is no standard way to link local variable.
You’ll have to use adhoc method. For example,

int main()
{
int var1=10 , var2;
const char *src=“var2 = var1 * 2;”;
G__init_cint(“cint”);
//Map variable var1 and var 2 here ???

 char com[100];
 sprintf(com,"int& var1=*(int*)%ld;",&var1);
 G__exec_text(com);
 sprintf(com,"int& var2=*(int*)%ld;",&var2);
 G__exec_text(com);

G__exec_text(src);
cout << var2 << endl; //this should print out “20”
// 10 * 2 G__scratch_all();
}

Thank you
Masa Goto

[/quote]

Philippe.

PS. Please avoid posting the same request on 2 different forums. Thanks,