Hello Axel,
Thanks a lot again. It is perfect for my purpose. It seems to be the most straightforward idea.
Regards,
-- OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu} Institute of Space and Astronautical Science (ISAS/JAXA) Now at KIPAC/SLAC/Stanford Varian Physics #306, 382 Via Pueblo Mall, MC 4060 Stanford, CA 94305-4060 TEL 650-736-0971/FAX 650-724-5065 Skype : okumura.akira On 2011/05/25, at 6:57, Axel Naumann wrote: > Hi, > > Long_t works, too. Otherwise use this approach: > > Say your function returns an object of class MyClass: > > MyClass func() > > Then you would invoke it like > > MyClass returnedObj; > TString expr = TString::Format("*(MyClass*)%p = func();", > (void*)&returnedObj); > gInterpreter->ProcessLine(expr); > > Cheers, Axel. > > OKUMURA, Akira wrote on 05/25/2011 03:13 PM: >> Hello Axel, >> >> Thank you. It works perfect for Int_t, but can I get other types or classes? >> >> Regards, >> >> -- >> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu} >> Institute of Space and Astronautical Science (ISAS/JAXA) >> Now at KIPAC/SLAC/Stanford >> Varian Physics #306, 382 Via Pueblo Mall, MC 4060 >> Stanford, CA 94305-4060 >> TEL 650-736-0971/FAX 650-724-5065 >> Skype : okumura.akira >> >> On 2011/05/25, at 5:49, Axel Naumann wrote: >> >>> Hi Akira, >>> >>> use >>> >>> gROOT->LoadMacro("MyMacro.C++"); // this macro contains Int_t MyFunc() >>> Int_t n = gInterpreter->ProcessLine("MyFunc()"); >>> >>> Cheers, Axel. >>> >>> >>> OKUMURA, Akira wrote on 05/25/2011 04:52 AM:Received on Wed May 25 2011 - 16:24:17 CEST
>>>> Hello ROOTers,
>>>>
>>>> I would like to know if there is any way to get the return value of a function which is loaded via TROOT::LoadMacro in a compiled code.
>>>>
>>>> Below is my conceptual code to be compiled by g++.
>>>>
>>>> int main()
>>>> {
>>>> (snip)
>>>> gROOT->LoadMacro("MyMacro.C++"); // this macro contains Int_t MyFunc()
>>>> Int_t n = MyFunc(); // How can I do this?
>>>> (snip)
>>>> }
>>>>
>>>> I would like to use MyMacro.C as a configuration file of the main program. The algorithm inside MyFunc() changes in each MyMacro.C. For example,
>>>>
>>>> --- MyMacro1.C ---
>>>> Int_t MyFunc()
>>>> {
>>>> return 1;
>>>> }
>>>>
>>>> --- MyMacro2.C ---
>>>> Int_t MyFunc()
>>>> {
>>>> return 2;
>>>> }
>>>>
>>>> Regards,
>>>>
>>>> --
>>>> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
>>>> Institute of Space and Astronautical Science (ISAS/JAXA)
>>>> Now at KIPAC/SLAC/Stanford
>>>> Varian Physics #306, 382 Via Pueblo Mall, MC 4060
>>>> Stanford, CA 94305-4060
>>>> TEL 650-736-0971/FAX 650-724-5065
>>>> Skype : okumura.akira
>>>>
>>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>> --
>>>> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
>>>> Institute of Space and Astronautical Science (ISAS/JAXA)
>>>> Now at KIPAC/SLAC/Stanford
>>>> Varian Physics #306, 382 Via Pueblo Mall, MC 4060
>>>> Stanford, CA 94305-4060
>>>> TEL 650-736-0971/FAX 650-724-5065
>>>> Skype : okumura.akira
>>>>
>>>>
>> >>
This archive was generated by hypermail 2.2.0 : Thu May 26 2011 - 05:50:01 CEST