Re:

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Tue, 14 Aug 2007 17:42:04 +0200


Hi Andrea,

yes, but the same scoping rules apply: the PrcessLine() script does not know about Proof()'s int a. Instead, pass it as into the called script as

TString inst = Form("int *a=0x%x; std::cout << \"a inside = \" << *a << std::endl;", &a;
gROOT->ProcessLine(inst);

Cheers, Axel.

Andrea Massironi wrote:
> Dear Rooters,
> I'd like to execute a Cint script contained in a string inside a file.cpp.
>
> For example:
>
> Proof.cpp
>
>
>
> void Proof(){
>
> int a = 1;
>
> std::string instruction;
>
> instruction = "a = 10; std::cout << std::endl << \"a inside = \" << a << std::endl;";
>
> gROOT->ProcessLine(instruction.c_str());
>
> std::cout << std::endl << "a outside = " << a << std::endl;
>
> }
>
>
>
> when I do
>

>> .x Proof.cpp

>
> I get
>
>> Warning: Automatic variable a is allocated (tmpfile):1:

>
>> a inside = 10

>
>> a outside = 1

>
>
>
> Is it possible to execute a cint script inside a file?
>
> thanks
>
>
>
Received on Tue Aug 14 2007 - 17:42:13 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 15 2007 - 17:50:02 CEST